|
|
| working directly with SAMPLE structure |
|
Kikaru
Member #7,616
August 2006
|
In my ever-living attempt to create a game maker utility, I decided to look at the Allegro SAMPLE structure. Well, it doesn't make a lot of sense. What I really want to know is: what is contained in the void *data;? Or better yet, what is the name of the allegro source file that contains that function? Thanks in advance! |
|
Richard Phipps
Member #1,632
November 2001
|
data is a pointer to the raw sample data held in memory. What exactly do you want to know? |
|
Kikaru
Member #7,616
August 2006
|
What does it do? What is the arrangement, of the data? |
|
Jonatan Hedborg
Member #4,886
July 2004
|
Unsigned char/short/long depending on the bits per sampling. first left then right (if stereo). Or the other way around
|
|
Kikaru
Member #7,616
August 2006
|
Is that frequency or amplitude? |
|
Jonatan Hedborg
Member #4,886
July 2004
|
It's the amplitude of that specific sampling (time).
|
|
Thomas Fjellstrom
Member #476
June 2000
|
Its standard raw PCM data. Something you can shove into a soundcard with little to no effort. -- |
|
Bruce Perry
Member #270
April 2000
|
Description of PCM, the format used by samples in Allegro. Sound is vibrations in the air. The analogue signal being sampled is the movements of the air particles as the wave passes through them, or the movements of the diaphragm in a microphone, or the movements of the cone in a speaker. The 'data' pointer points to an array of either unsigned chars or unsigned shorts (not longs in Allegro). The value 0x80 or 0x8000 corresponds to equilibrium. A long line of 0x80 or 0x8000 represents silence. Any other data should oscillate around this value, although it often doesn't if the microphone used to record it was cheap. If you are processing these data, make sure the values don't overflow. That will sound ghastly. If there is a risk of overflow, you should clamp the values to the maximum/minimum, which sounds a bit bad but still OK. Have fun Note: the values are not the amplitude, they are the elongation. The amplitude is the maximum elongation that a wave reaches, and thus describes the strength of the wave as a whole. -- |
|
Kikaru
Member #7,616
August 2006
|
Ok. Thanks for the link! I am trying to work out how to make an all-in-one file packing format that I can save and load to for my stuff. |
|
Jonatan Hedborg
Member #4,886
July 2004
|
uhm... you mean something like datafiles?
|
|
Kikaru
Member #7,616
August 2006
|
No, custom. I am going to work on my own compression format (half-done already), and the file can contain images, sounds, and maybe some extra data, for use with my own app only (I want to make a game creator). |
|
Jonatan Hedborg
Member #4,886
July 2004
|
Alright. Any special reason why you want to re-invent the wheel? If you don't like this particular wheel there are other wheels that you might like better
|
|
Kikaru
Member #7,616
August 2006
|
I have 2 reasons: 1) I like working with files, and this seems fun. 2) It is also known as "practice." |
|
|