Hello, everybody. :]
I would like to know how I can get programmable sounds and music (8 or 16-bit style, primarily) to work with the SFML or SDL libraries. Concepts alone would help, and hopefully I could find a way to make it work either way, but I'm somewhat at a loss presently. I could just import sound effects in .wav or whatever other format, but I'm interested in seeing if it's possible to get them to work in a programming sense, much like it used to be back in the day. Any help at all would be greatly appreciated :]
And if it makes any difference, I'm programming on a Mac, OS 10.5, on a MacBook.
Thank you all in advance.
Colton
Programmable Sounds and Music
By programmable, I mean more toward rendering the audio by the program as opposed to importing an audio sample and having the program simply play it like an audio player would. I messed with a Commodore 64 emulator once and you were given the ability to use BASIC and program sounds for it. SFML doesn't really have any midi support, but it looks like SDL does.... would this be a good first place to start?
Ok. What you want doesn't really exist at that level in these libraries because there's hardly any call for it these days.
You can write it yourself, by producing code that writes directly into the audio buffer that is being played back. This requires an understanding of frequency, amplitude, and waveform functions. For example if you want to play a sine wave at 440Hz for a second, you fill 1/440th of a second's worth of buffer space with the values of sin(0) to sin(2*pi) multiplied by the required amplitude, and repeat that another 439 times to fill up a second of sound.
It's probably not worth the effort unless this is critical to your program.
MIDI probably isn't really relevant here as you get no control over the type of sound being played. SDL can play midi files but it doesn't really have any midi support beyond that so you can't construct your own tunes that way.
You can write it yourself, by producing code that writes directly into the audio buffer that is being played back. This requires an understanding of frequency, amplitude, and waveform functions. For example if you want to play a sine wave at 440Hz for a second, you fill 1/440th of a second's worth of buffer space with the values of sin(0) to sin(2*pi) multiplied by the required amplitude, and repeat that another 439 times to fill up a second of sound.
It's probably not worth the effort unless this is critical to your program.
MIDI probably isn't really relevant here as you get no control over the type of sound being played. SDL can play midi files but it doesn't really have any midi support beyond that so you can't construct your own tunes that way.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement