开发者

Rendering some sound data into one new sound data?

I'm creating an application that will read a unique format that 开发者_运维技巧contains sound "bank" and offsets when the sound must be played.

Imagine something like..

Sound bank: (ID on the left-hand and file name on the right-hand side)

0 kick.wav
1 hit.wav
2 flute.wav

And the offsets: (Time in ms on the left-hand and sound ID on the right-hand side)

1000 0
2000 1
3000 2

And the application will generate a new sound file (ie. wav, for later conversion to other formats) that plays a kick at first sec, a hit at second sec, and flute at third sec.

I completely have no idea on where to begin.

I usually use FMOD for audio playbacks, but never did something like this before.

I'm using C++ and wxWidgets on a MSVC++ Express Edition environment, and LGPL libraries would be fine.


If I understand correctly, you want to generate a new wave file by mixing wavs from a soundbank. You may not need a sound API at all for this, especially if all your input wavs are in the same format.

Simply load each wav file into a buffer. For SampleRate*secondsUntilStartTime samples, for each buffer in the ActiveList, add buffer[bufferIdx++] into the output buffer. If bufferIdx == bufferLen, remove this buffer from the ActiveList. At StartTime, add the next buffer the ActiveList, and repeat.

If FMOD supports output to a file instead of the sound hardware, you can do this same thing with the streaming API. Just keep track of elapsed samples in the StreamCallback, and start mixing in new files whenever you reach their start offsets.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜