![]() |
|
Allegro 5 dynamically created samples |
Don Freeman
Member #5,110
October 2004
![]() |
Sorry if this has been asked and answered before, but my google foo has not been great with this. So basically I am wanting to create real time audio effects with Allegro 5, but am kind of at a loss as to how to go about that. What I found seems to suggest creating an ALLEGRO_SAMPLE using al_create_sample with my own data but I'm confused as to what that data actually represents. Is it the amplitude of the sound at certain intervals of time? Any help clarifying this would be extremely grateful. Thanks in advance, -- |
Chris Katko
Member #1,881
January 2002
![]() |
I looked into this MANY YEARS ago. But IIRC, it is raw waveform data as in, positions of the speaker. say, 0 = full retracted, 255 = full extended. Allegro should be using the same as any other API, so other API tutorials should be applicable: https://medium.com/programming-for-music/generating-raw-audio-samples-f08f3adf73af Also, IIRC, there should be at least one raw audio generate example in Allegro 5's example folder. -----sig: |
Mark Oates
Member #1,146
March 2001
![]() |
It depends on the sample format, but you can imagine a waveform graphic having a center line, the wave is sampled as many points progressing forward in time (towards the right) as sample values at the minimum (-1.0f), to values at the maximum (1.0f) and everything in between, (0.0 in the center). In this case, the samples represent the amplitude. Again, depending on the sample format, those values could be floating 0.0 to 1.0, with 0.5 being the center; or 0 to 255, with 128 being the center, 0 to 65536, or -1.0...1.0 being the top. That's called the "DEPTH". Some sample depths include ALLEGRO_AUDIO_DEPTH_INT16, ALLEGRO_AUDIO_DEPTH_INT8, etc. Here are the depth types: https://liballeg.org/a5docs/trunk/audio.html#allegro_audio_depth Also, here's some code that renders an ALLEGRO_SAMPLE, which might be helpful: https://github.com/allegroflare/allegro_flare/blob/master/include/allegro_flare/sample_renderer.h -- |
Chris Katko
Member #1,881
January 2002
![]() |
-----sig: |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Basically, you need a waveform, an amplitude form, and a pitch form to create a sound wave. You combine the three to make your sound. Waveform goes from -1.0 to 1.0, amplitude goes from 0.0 to 1.0 and pitch goes from something like 20Hz to 20000Hz (waves per second). My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|