mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
audio: Bug fix: Adjust data size after resampling
This commit is contained in:
parent
bb435b7296
commit
2439d407df
@ -191,6 +191,7 @@ func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) {
|
|||||||
}
|
}
|
||||||
if sampleRate != context.SampleRate() {
|
if sampleRate != context.SampleRate() {
|
||||||
s = convert.NewResampling(s, size, sampleRate, context.SampleRate())
|
s = convert.NewResampling(s, size, sampleRate, context.SampleRate())
|
||||||
|
size = size * int64(context.SampleRate()) / int64(sampleRate)
|
||||||
}
|
}
|
||||||
return &Stream{s, size}, nil
|
return &Stream{s, size}, nil
|
||||||
}
|
}
|
||||||
|
@ -213,6 +213,7 @@ chunks:
|
|||||||
}
|
}
|
||||||
if sampleRateFrom != sampleRateTo {
|
if sampleRateFrom != sampleRateTo {
|
||||||
s = convert.NewResampling(s, dataSize, sampleRateFrom, sampleRateTo)
|
s = convert.NewResampling(s, dataSize, sampleRateFrom, sampleRateTo)
|
||||||
|
dataSize = dataSize * int64(sampleRateTo) / int64(sampleRateFrom)
|
||||||
}
|
}
|
||||||
return &Stream{s, dataSize}, nil
|
return &Stream{s, dataSize}, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user