Hi everyone, I need some help to write a sound manager to play background music and special sound effects at the same time in the VB hardware… I have very little knowledge about sound stuff… and I don’t know if the problem I have thought of is not a real world one, but it seems I very tricky problem. So if anyone have experience, or has a good link reference would be of great help.
Just to be clear… I need a very clean, compact and optimized algorithm which must run inside a timer interrupt, so i doesn’t distort the time measurement.
Right now I can play background music OR special sound effects (thanks to Krisse and DogP).. but can’t play multiple sounds at the same time (no at least if the total number of notes in all the sounds played at a given time surpasses the number of available channels) .
Hmm… I’m not sure that I understand what you’re wanting. You can’t have more than 6 channels (4 regular + 1 sweep/mod + 1 noise) playing no matter what. IMO the best way would be to have the music and sound data in memory, and then have the interrupt service routine just load the next note (frequency, volume, etc). Of course you’ll need to use seperate channels for background music and sound effects, and also for multiple sound effects.
You’ll just need to set up your music and sounds to have a duration of a multiple of your interrupt (faster interrupt would give you the ability to change notes faster, but take more memory, longer notes would take less memory, but of course give you less control of the sound). You should be able to find a medium point that works well for you. And I don’t remember exactly how the interrupts work on the VB, but IIRC they can be triggered at a constant rate, regardless of how long the interrupt service routine takes (so just arrange the music using that as a base speed).
I’d limit background music to 2 channels max, which would give you 2 regular channels for sound effects, 1 sweep/modulation channel for speech, or it can also be used as another regular channel, and then one noise channel for random sounds like a helicopter or something.
Let me know if this answers any of your questions or if I’m not understanding what you’re asking.
Hey DogP, I thought of that too… to have 2 dedicated channels for BGM, and the other 3 for sound effects, until I saw your code and realized that a given sound (bgm or special effect) can use more than 2 notes at a time… that’s why I came to think that I need to create an “on demand solution”… but I f there is enough to have 2 channels for BGM I can live with that… which as a side effect (a good one indeed), makes the algorithm a lot lighter, having not to worry about the interrupt to be to long.
PS: by the way… have you noticed that the development forums (and scene) have been to much quiet the last 6 months or so… would be cool if more people get involved.
Yeah, in my demo I basically converted a multi channel .mod file to the VB to get that song… there’s no need for the extra channels to get good sounding music, it just gives you more to play with.
And yeah, it has definitely been too quiet around here… hopefully some new dev’rs will show up when they get their hands on a flashboy.