home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Dream 59
/
CDDream59.ISO
/
BeOs
/
Sound
/
Intel
/
PPBeDevKit.ZIP
/
PLAYERPR.TAR
/
PlayerPRO
/
Source
/
Mac-SoundManager.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-12-26
|
4KB
|
131 lines
/******************** ***********************/
//
// Player PRO 5.0 - DRIVER SOURCE CODE -
//
// Library Version 5.0
//
// To use with MAD Library for Mac: Symantec, CodeWarrior and MPW
//
// Antoine ROSSET
// 16 Tranchees
// 1206 GENEVA
// SWITZERLAND
//
// COPYRIGHT ANTOINE ROSSET 1996, 1997, 1998
//
// Thank you for your interest in PlayerPRO !
//
// FAX: (+41 22) 346 11 97
// PHONE: (+41 79) 203 74 62
// Internet: RossetAntoine@bluewin.ch
//
/******************** ***********************/
#include "RDriver.h"
#include "RDriverInt.h"
/*************************/
SndChannelPtr CreateSndChannel( long init)
{
SndChannelPtr mySndChan; // pointer to a sound channel
OSErr myErr;
mySndChan = 0L;
myErr = SndNewChannel( &mySndChan, sampledSynth, init, nil);
return mySndChan; // return SndChannelPtr
}
OSErr DBSndClose( MADDriverRec *inMADDriver)
{
OSErr err;
short i;
err = SndDisposeChannel( inMADDriver->MusicChannelPP, true);
inMADDriver->MusicChannelPP = 0L;
DisposeRoutineDescriptor( (UniversalProcPtr) inMADDriver->TheHeader.dbhDoubleBack);
inMADDriver->TheHeader.dbhDoubleBack = 0L;
for ( i = 0; i <= 1; i++) { DisposePtr( (Ptr) inMADDriver->TheHeader.dbhBufferPtr[i]); inMADDriver->TheHeader.dbhBufferPtr[i] = 0L;}
return noErr;
}
OSErr InitDBSoundManager( MADDriverRec *inMADDriver, long init)
{
OSErr err = noErr;
inMADDriver->MusicChannelPP = 0L;
inMADDriver->MusicChannelPP = CreateSndChannel( init);
if( inMADDriver->MusicChannelPP == 0L) return MADSoundManagerErr;
err = DBSndPlay( inMADDriver, inMADDriver->MusicChannelPP);
return err;
}
OSErr DBSndPlay ( MADDriverRec *inMADDriver, SndChannelPtr chan)
{
SndDoubleBufferPtr doubleBuffer;
short i;
OSErr err = noErr;
inMADDriver->TheHeader.dbhCompressionID = 0;
inMADDriver->TheHeader.dbhPacketSize = 0;
inMADDriver->TheHeader.dbhDoubleBack = NewSndDoubleBackProc( &MyDoubleBackProc);
inMADDriver->TheHeader.dbhSampleRate = inMADDriver->DriverSettings.outPutRate;
inMADDriver->TheHeader.dbhSampleSize = inMADDriver->DriverSettings.outPutBits;
// if( inMADDriver->DriverSettings.outPutMode == MonoOutPut) inMADDriver->TheHeader.dbhNumChannels = 1;
// else
inMADDriver->TheHeader.dbhNumChannels = 2;
for (i = 0; i <= 1; i++)
{
doubleBuffer = (SndDoubleBufferPtr) MADNewPtrClear( sizeof (SndDoubleBuffer) + inMADDriver->BufSize + 20L, inMADDriver->lib);
if( doubleBuffer == 0L) return MADNeedMemory;
doubleBuffer->dbNumFrames = 0;
doubleBuffer->dbFlags = 0;
doubleBuffer->dbUserInfo[ 0] = (long) inMADDriver;
MyDoubleBackProc( chan, doubleBuffer);
inMADDriver->TheHeader.dbhBufferPtr[i] = doubleBuffer;
}
err = SndPlayDoubleBuffer( chan, &inMADDriver->TheHeader);
if( err != noErr) return MADSoundManagerErr;
return err;
}
void StopChannel( MADDriverRec *inMADDriver)
{
SndCommand cmd;
cmd.cmd = quietCmd;
cmd.param1 = 0;
cmd.param2 = 0;
SndDoImmediate( inMADDriver->MusicChannelPP, &cmd);
cmd.cmd = flushCmd;
cmd.param1 = 0;
cmd.param2 = 0;
SndDoImmediate( inMADDriver->MusicChannelPP, &cmd);
}
void PlayChannel( MADDriverRec *inMADDriver)
{
OSErr iErr;
MyDoubleBackProc( inMADDriver->MusicChannelPP, inMADDriver->TheHeader.dbhBufferPtr[ 0]);
MyDoubleBackProc( inMADDriver->MusicChannelPP, inMADDriver->TheHeader.dbhBufferPtr[ 1]);
iErr = SndPlayDoubleBuffer( inMADDriver->MusicChannelPP, &inMADDriver->TheHeader);
}