Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default format to 22050 from 22500 #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions float_buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand All @@ -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)
Expand All @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions formats.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ package audio
var (
// MONO

// FormatMono22050 is mono 22.05kHz format.
FormatMono22050 = &Format{
NumChannels: 1,
SampleRate: 22050,
}
// FormatMono22500 is mono 22.5kHz format.
FormatMono22500 = &Format{
Copy link

@egonelbre egonelbre May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a backwards incompatible change. Let's add 22.05khz as an additional format rather than modifying the existing FormatMono22500.

PS: changing the tests is fine.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review!
Restored 22500 format.

NumChannels: 1,
Expand All @@ -26,6 +31,11 @@ var (

// STEREO

// FormatStereo22050 is stereo 22.05kHz format.
FormatStereo22050 = &Format{
NumChannels: 2,
SampleRate: 22050,
}
// FormatStereo22500 is stereo 22.5kHz format.
FormatStereo22500 = &Format{
NumChannels: 2,
Expand Down