Skip to content

Commit e65f416

Browse files
committed
style: align inline comments and formatting
- Align inline comments in test files for readability - Reformat SOXR formula comments to code block style - Align const declarations - No functional changes
1 parent a346ebe commit e65f416

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

cmd/resample-wav/helpers_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func TestOpenWAVInput_InvalidWAV(t *testing.T) {
3131

3232
func TestCreateChannelResamplers_Mono(t *testing.T) {
3333
resamplers, err := createChannelResamplers[float64](
34-
1, // mono
34+
1, // mono
3535
44100, 48000, // rates
3636
engine.QualityHigh,
3737
)
@@ -42,7 +42,7 @@ func TestCreateChannelResamplers_Mono(t *testing.T) {
4242

4343
func TestCreateChannelResamplers_Stereo(t *testing.T) {
4444
resamplers, err := createChannelResamplers[float64](
45-
2, // stereo
45+
2, // stereo
4646
44100, 48000, // rates
4747
engine.QualityHigh,
4848
)
@@ -54,7 +54,7 @@ func TestCreateChannelResamplers_Stereo(t *testing.T) {
5454

5555
func TestCreateChannelResamplers_Multichannel(t *testing.T) {
5656
resamplers, err := createChannelResamplers[float64](
57-
8, // 7.1 surround
57+
8, // 7.1 surround
5858
44100, 48000, // rates
5959
engine.QualityHigh,
6060
)
@@ -99,8 +99,8 @@ func TestNewResampleBuffers(t *testing.T) {
9999
NumChannels: 2,
100100
}
101101
buffers := newResampleBuffers[float64](
102-
2, // stereo
103-
16, // 16-bit
102+
2, // stereo
103+
16, // 16-bit
104104
44100, 48000, // rates
105105
format,
106106
)
@@ -142,7 +142,7 @@ func TestProgressTracker_ZeroSamples(t *testing.T) {
142142
func TestResampleSequential_Success(t *testing.T) {
143143
// Create resamplers
144144
resamplers, err := createChannelResamplers[float64](
145-
2, // stereo
145+
2, // stereo
146146
44100, 48000, // rates
147147
engine.QualityHigh,
148148
)
@@ -172,7 +172,7 @@ func TestResampleSequential_Success(t *testing.T) {
172172
func TestResampleParallel_Success(t *testing.T) {
173173
// Create resamplers
174174
resamplers, err := createChannelResamplers[float64](
175-
2, // stereo
175+
2, // stereo
176176
44100, 48000, // rates
177177
engine.QualityHigh,
178178
)
@@ -202,7 +202,7 @@ func TestResampleParallel_Success(t *testing.T) {
202202
func TestResampleChannelData_ParallelMode(t *testing.T) {
203203
// Create resamplers
204204
resamplers, err := createChannelResamplers[float64](
205-
2, // stereo
205+
2, // stereo
206206
44100, 48000, // rates
207207
engine.QualityHigh,
208208
)
@@ -223,7 +223,7 @@ func TestResampleChannelData_ParallelMode(t *testing.T) {
223223
func TestResampleChannelData_SequentialMode(t *testing.T) {
224224
// Create resamplers
225225
resamplers, err := createChannelResamplers[float64](
226-
2, // stereo
226+
2, // stereo
227227
44100, 48000, // rates
228228
engine.QualityHigh,
229229
)
@@ -244,7 +244,7 @@ func TestResampleChannelData_SequentialMode(t *testing.T) {
244244
func TestResampleChannelData_MonoFallsBackToSequential(t *testing.T) {
245245
// Create mono resampler
246246
resamplers, err := createChannelResamplers[float64](
247-
1, // mono
247+
1, // mono
248248
44100, 48000, // rates
249249
engine.QualityHigh,
250250
)
@@ -264,7 +264,7 @@ func TestResampleChannelData_MonoFallsBackToSequential(t *testing.T) {
264264
func TestFlushAndPadChannels_EqualLengths(t *testing.T) {
265265
// Create resamplers
266266
resamplers, err := createChannelResamplers[float64](
267-
2, // stereo
267+
2, // stereo
268268
44100, 48000, // rates
269269
engine.QualityHigh,
270270
)
@@ -291,7 +291,7 @@ func TestFlushAndPadChannels_EqualLengths(t *testing.T) {
291291
func TestFlushAndPadChannels_EmptyFlush(t *testing.T) {
292292
// Create resamplers but don't process any data
293293
resamplers, err := createChannelResamplers[float64](
294-
2, // stereo
294+
2, // stereo
295295
44100, 48000, // rates
296296
engine.QualityHigh,
297297
)

internal/engine/cubic.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ func (c *CubicStage[F]) Process(input []F) ([]F, error) {
6565
// where x is the fractional position between samples.
6666
//
6767
// SOXR formula from cr-core.c:59-61:
68-
// b = 0.5*(s[1]+s[-1]) - s[0]
69-
// a = (1/6)*(s[2]-s[1]+s[-1]-s[0] - 4*b)
70-
// coefC = s[1] - s[0] - a - b
68+
//
69+
// b = 0.5*(s[1]+s[-1]) - s[0]
70+
// a = (1/6)*(s[2]-s[1]+s[-1]-s[0] - 4*b)
71+
// coefC = s[1] - s[0] - a - b
7172
func (c *CubicStage[F]) interpolate(x float64) F {
7273
// Get the 4 points for interpolation
7374
// Map to SOXR's convention: s[-1], s[0], s[1], s[2]
@@ -77,7 +78,7 @@ func (c *CubicStage[F]) interpolate(x float64) F {
7778
s2 := float64(c.history[0]) // newest = s[2]
7879

7980
// SOXR's cubic formula (from cr-core.c:59-61)
80-
b := 0.5*(s1+sMinus1) - s0 //nolint:mnd // Mathematical constant from SOXR formula
81+
b := 0.5*(s1+sMinus1) - s0 //nolint:mnd // Mathematical constant from SOXR formula
8182
a := (1.0 / 6.0) * (s2 - s1 + sMinus1 - s0 - 4*b) //nolint:mnd // Mathematical constant from SOXR formula
8283
coefC := s1 - s0 - a - b
8384

internal/engine/edge_cases_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -499,16 +499,16 @@ func TestNewResampler_InvalidRates(t *testing.T) {
499499
wantErr bool
500500
}{
501501
{"valid_rates", 44100, 48000, false},
502-
{"valid_max_ratio", 1000, 256000, false}, // ratio = 256 (max)
503-
{"valid_min_ratio", 256000, 1000, false}, // ratio = 1/256 (min)
502+
{"valid_max_ratio", 1000, 256000, false}, // ratio = 256 (max)
503+
{"valid_min_ratio", 256000, 1000, false}, // ratio = 1/256 (min)
504504
{"zero_input", 0, 48000, true},
505505
{"zero_output", 44100, 0, true},
506506
{"negative_input", -44100, 48000, true},
507507
{"negative_output", 44100, -48000, true},
508508
{"both_zero", 0, 0, true},
509-
{"ratio_too_large", 1000, 300000, true}, // ratio = 300 (> 256)
510-
{"ratio_too_small", 300000, 1000, true}, // ratio = 1/300 (< 1/256)
511-
{"extreme_ratio", 1000, 1e9, true}, // ratio = 1e6 (way too large)
509+
{"ratio_too_large", 1000, 300000, true}, // ratio = 300 (> 256)
510+
{"ratio_too_small", 300000, 1000, true}, // ratio = 1/300 (< 1/256)
511+
{"extreme_ratio", 1000, 1e9, true}, // ratio = 1e6 (way too large)
512512
}
513513

514514
for _, tc := range testCases {

internal/engine/polyphase.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ func NewResampler[F simdops.Float](inputRate, outputRate float64, quality Qualit
5858
// Following SOXR's pattern: ratios between 1/256 and 256 are practical for audio.
5959
// Extreme ratios can cause: (1) integer overflow in output size calculation,
6060
// (2) memory exhaustion from attempting to allocate huge output buffers.
61-
const minRatio = 1.0 / 256.0 // 256x downsampling
62-
const maxRatio = 256.0 // 256x upsampling
61+
const minRatio = 1.0 / 256.0 // 256x downsampling
62+
const maxRatio = 256.0 // 256x upsampling
6363
if ratio < minRatio || ratio > maxRatio {
6464
return nil, fmt.Errorf("resampling ratio %.6f out of valid range [%.6f, %.0f]", ratio, minRatio, maxRatio)
6565
}

0 commit comments

Comments
 (0)