From eb26905eb0f7930c484e4290d2349eb02dcea1ce Mon Sep 17 00:00:00 2001 From: munenari Date: Tue, 21 May 2024 11:52:50 +0900 Subject: [PATCH 1/2] Change default format to 22050 from 22500 --- float_buffer_test.go | 10 +++++----- formats.go | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/float_buffer_test.go b/float_buffer_test.go index 3b999c6..ebe19e4 100644 --- a/float_buffer_test.go +++ b/float_buffer_test.go @@ -19,7 +19,7 @@ func TestFloat64Buffer(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - fb := FloatBuffer{Format: FormatMono22500, Data: tt.f64} + fb := FloatBuffer{Format: FormatMono22050, Data: tt.f64} fb32 := fb.AsFloat32Buffer() if !reflect.DeepEqual(fb32.Data, tt.f32) { t.Errorf("Expected %+v got %+v", tt.f32, fb32.Data) @@ -45,7 +45,7 @@ func TestClone(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - fb := FloatBuffer{Format: FormatMono22500, Data: tt.f64} + fb := FloatBuffer{Format: FormatMono22050, Data: tt.f64} b := fb.Clone() fb2 := b.AsFloatBuffer() if !reflect.DeepEqual(fb2.Data, tt.f64) { @@ -67,12 +67,12 @@ func TestClone(t *testing.T) { func TestNumFrames(t *testing.T) { expect := 3 - fb64 := FloatBuffer{Format: FormatMono22500, Data: []float64{1, 2, 3}} + fb64 := FloatBuffer{Format: FormatMono22050, Data: []float64{1, 2, 3}} numFrames := fb64.NumFrames() if numFrames != expect { t.Errorf("Expected %d got %d", expect, numFrames) } - fb32 := Float32Buffer{Format: FormatMono22500, Data: []float32{1, 2, 3}} + fb32 := Float32Buffer{Format: FormatMono22050, Data: []float32{1, 2, 3}} numFrames = fb32.NumFrames() if numFrames != expect { t.Errorf("Expected %d got %d", expect, numFrames) @@ -92,7 +92,7 @@ func TestFloat32Buffer(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - fb := Float32Buffer{Format: FormatMono22500, Data: tt.f32} + fb := Float32Buffer{Format: FormatMono22050, Data: tt.f32} fb64 := fb.AsFloatBuffer() if !reflect.DeepEqual(fb64.Data, tt.f64) { t.Errorf("Expected %+v got %+v", tt.f64, fb64.Data) diff --git a/formats.go b/formats.go index 215bbb8..86aa4cd 100644 --- a/formats.go +++ b/formats.go @@ -3,10 +3,10 @@ package audio var ( // MONO - // FormatMono22500 is mono 22.5kHz format. - FormatMono22500 = &Format{ + // FormatMono22050 is mono 22.05kHz format. + FormatMono22050 = &Format{ NumChannels: 1, - SampleRate: 22500, + SampleRate: 22050, } // FormatMono44100 is mono 8bit 44.1kHz format. FormatMono44100 = &Format{ @@ -26,10 +26,10 @@ var ( // STEREO - // FormatStereo22500 is stereo 22.5kHz format. - FormatStereo22500 = &Format{ + // FormatStereo22050 is stereo 22.05kHz format. + FormatStereo22050 = &Format{ NumChannels: 2, - SampleRate: 22500, + SampleRate: 22050, } // FormatStereo44100 is stereo 8bit 44.1kHz format. FormatStereo44100 = &Format{ From 81971809b5c2fd2bfff712090db5445ff99ca303 Mon Sep 17 00:00:00 2001 From: munenari Date: Wed, 22 May 2024 09:43:55 +0900 Subject: [PATCH 2/2] Reenabled 22500 for retaining backwards incompatible --- formats.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/formats.go b/formats.go index 86aa4cd..f030d2b 100644 --- a/formats.go +++ b/formats.go @@ -8,6 +8,11 @@ var ( NumChannels: 1, SampleRate: 22050, } + // FormatMono22500 is mono 22.5kHz format. + FormatMono22500 = &Format{ + NumChannels: 1, + SampleRate: 22500, + } // FormatMono44100 is mono 8bit 44.1kHz format. FormatMono44100 = &Format{ NumChannels: 1, @@ -31,6 +36,11 @@ var ( NumChannels: 2, SampleRate: 22050, } + // FormatStereo22500 is stereo 22.5kHz format. + FormatStereo22500 = &Format{ + NumChannels: 2, + SampleRate: 22500, + } // FormatStereo44100 is stereo 8bit 44.1kHz format. FormatStereo44100 = &Format{ NumChannels: 2,