Audio: "pops" when playing many soundfiles

BlitzMax Forums/BlitzMax Programming/Audio: "pops" when playing many soundfiles

Capirola(Posted 2013) [#1]
Hello!

I'm currently working on a relatively simple and straight-forward program which works a bit like a music box. The user enters little dots for notes and can play back the composition by pressing the space bar repeatedly for every bar.

For every note (C,C#,D, Eb etc...) I imported an .ogg-soundfile and play it over a channel (I allocated a channel for every pitch so that many notes can be played at once) when the keypress is done.

The problem is that especially when playing the same note in quick succession and several chords after one another the audio sort of "clicks" and "pops". It sounds like some kind of clipping.

Is there some kind of effective way to play many soundfiles in a Blitzmax-application simultaneously with a smooth sound and no "pops"?

Any Help is very much appreciated. :-)


xlsior(Posted 2013) [#2]
Are you recycling the channels you play them over, or are you creating/destroying a new channel for each sample that you play?


Capirola(Posted 2013) [#3]
I tried both:

first I tried to allocate Channels in an Array of TChannel-Objects with 1 channel assigned to every note pitch (A, B, C, D etc.) and then I would simply play the notes in the same channels over and over again but that would already create some unpleasent popping noises.

What I tried then, just for kicks, was to simply "PlaySound" a file everytime a note was played. The clicking seemed to be (hopefully) solved but I would still get unpleasant sounds when playing many notes together. But then I remembered that the sounds themselves were already relatively loud audio. They weren't clipping themselves but relatively close. So I exported all the sound files again, this time with some dB less and now it seems to sound quite good on the hand, but now there are two other problems:
1.) the individual notes are now pretty quiet. I have to turn up my speakers quite a bit and the whole audio of the program still seems too quiet. I could of course tell the program to play notes more quiet depending on how many notes are sounding.
2.) if I want to stop the playback of a particular sound, how do I do that? Doesn't BlitzMax allocate a new channel automatically when I simply play a sound? Is there a way of finding out the handle of that channel so I can manipulate it?

***the short version***:
Is there a way to find out the handle of a Channel that blitzmax automatically creates when I play a sound without assigning a channel?


Yan(Posted 2013) [#4]
PlaySound() returns the channel it uses.


Capirola(Posted 2013) [#5]
Thank you very much, I think I can figure something out now!

Just one more question: is it generally a bad idea to not even bother much with allocating channels and just let the program create new channels all the time (so basically just using "PlaySound()")? Will this overly stress the Memory or anything like that? Or don't I really have to worry about that too much?


Pineapple(Posted 2013) [#6]
I was having similar issues using OpenAL, so I switched to DirectSound and things seemed to be fine.


Pineapple(Posted 2013) [#7]
I was having similar issues using OpenAL, so I switched to DirectSound and things seemed to be fine.


wad(Posted 2013) [#8]
i have written a SpecDrum clone (the old days of the spectrum 48k) using blitzmax and i use directsound in my program and i have upto 20 samples playing at once with no pop or click but i do suffer when it comes to windows 7 or windows 8 when i use directsound i get slight latency , but there again that could be the creative drivers for my audigy 4 platinum.

the one thing i would like to get into is using Asio sound drivers but maybe i am not looking in the right place but can't seem to find any in here

Lee