if (Locksnd()==1) {
Setmontrack(0); /* set output to first track */
Settrack(0,1); /* set number of tracks to 1 playback */
Setmode(res); /* res: 0=8bit stereo, 1=16bit stereo, 2=8bit mono */
}
else printf("Sorry, sound system is locked.");
The following will then play the actual sample...
Soundcmd(value,6); /* value : determines frequency (see below) */
Setbuffer(mode,sambegin,samend); /* mode: 0=play, 1=record. sambegin/end are addresses */
Devconnect(0,8,0,scale,0); /* connect DMA play to DAC. scale determines frequency */
Buffoper(mode); /* mode: 0=stop, 1=play, 3=play with loop. */
The frequency is determined by the prescale value. Below is a table which gives the frequency for each value. Any value not listed will give a mute condition.
scale freq (Hz) value passed in Soundcmd(value,6); 11 8195 - 9 9834 - 7 12292 - 5 16390 - 4 19668 - 3 24585 - 2 32780 - 1 49170 - 0 125?? 1 0 25033 2 0 50066 3 ( - means no effect.)Of course, you must not forget to unlock the sound sub-system before you terminate your program, as other applications will still be told that you are using it. (although it is possible to ignore this...)
Unlocksnd();