home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Audio 4.94 - Over 11,000 Files
/
audio-11000.iso
/
msdos
/
sndbords
/
proaudio
/
sdk_ex
/
sdk_ex.arj
/
SDK_EX1.C
next >
Wrap
C/C++ Source or Header
|
1993-10-17
|
2KB
|
71 lines
/*
* Program: SDK_EX1.C
* Author: Philip VanBaren
* Purpose: This program demonstrates how to use the Media Vision SDK routines
* to do output a single block of data.
*/
#include <math.h>
#include <stdio.h>
#include <conio.h>
#include <pcmio.h>
extern int DMARunning; /* SDK flag that indicates when DMA has been started */
#define IRQ -1 /* -1 means use the default value */
#define DMA -1 /* -1 means use the default value */
#define DMASize 16 /* 16k DMA buffer */
#define DMADivisions 4 /* 4 divisions in this buffer */
#define SamplingRate 22050
#define StereoFlag 0 /* If this flag is 1, data is interleaved left/right */
#define CompressionFlag 0
#define SampleSize 16 /* Size of samples, 8 or 16 bits */
#define BUF_LEN 20000
int out_buf[BUF_LEN];
void main(void)
{
/*
* Put some meaningful information in out_buf here
*/
int i;
for(i=0;i<BUF_LEN;i++)
out_buf[i]=floor(20000*sin(2*M_PI*0.1*i));
/*
* Initialize ProAudio stuff
*/
if(OpenPCMBuffering(DMA,IRQ,DMASize,DMADivisions)!=0)
puts("Error trying to open PCM buffering.");
else if(PCMState(SamplingRate,StereoFlag,CompressionFlag,SampleSize)!=0)
puts("Error setting sample rate.");
else
{
if(PlayThisBlock((char *)out_buf,(long)BUF_LEN*2,NULL)!=0)
{
ClosePCMBuffering();
puts("Error playing block.");
}
else
{
/*
* Wait for the DMA to end (which means playback is complete).
*/
while(!kbhit() && DMARunning);
}
}
/*
* You MUST call this function before ending the program, else things won't
* work right the next time you try to run the program. This is critical to
* remember when debugging the program, because in debugging you often quit the
* program before it runs to completion. The only way I know of to recover
* if this function is NOT called is to reboot the computer!
*/
ClosePCMBuffering();
}