April 18, 2024, 07:16:40 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Single channel wave sampler

Started by sapero, October 30, 2007, 12:39:14 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sapero

October 30, 2007, 12:39:14 PM Last Edit: October 30, 2007, 01:13:38 PM by sapero
This is my first sound sampler, based on simple windows timer running in a thread with highest (realtime) priority.
Samples are loaded into direct sound buffers (one buffer per sample) and when the timer is signalled, one of the buffers is forced to play.
Sampler data is stored in a string, where "0" means "play now the first buffer", "1" - second..., "." - pause, and "+" - play looping.
To create base techno rhytm, you need only two audio samples (bass+treble), and sampler data in format "01".

The main window has a combobox with 7 predefined rhytms, and a number-editbox representing tempo (timer interval). Combo is editable, so you can create new rhytms.

In /old folder you find the first working, and easy to understand algorithm. Current version uses additional class (CSampler1) to load, play the samples, and transparently install subclass on main window to receive timer events.

I've decided to compress wave files into single mp3 file and split it back, to save the lenght of attached zip (wavs:500k, mp3:94k)
The decompression and spliting is done inside MP3Split class.
I've used Audacity to merge wavs and save as single mp3 file, then after decompressing the mp3 file into one large wave, I was able to calculate (see) durations of all samples, required to cut the mp3 (see sub ExtractWavs in main.src).
The MP3Split class uses DirectShow interfaces with NULL-renderer in order to grab PCM audio samples and save it as wave files.

Unpack, compile or run the program - it will show a message that will unpack and cut the mp3 file with merged samples. Click OK, and wait a while until main window is not visible. It will took 10 seconds.

ExMember001

looks and sound very good !
It makes me want to do some audio coding again :)