When a developer has already provided an interface for the specific Input, the user can set up the Input device easily by calling
if(audiofile == NULL) { audiofile = InputAudioStreamCreate("c:\test.mp2"); *audiofile >> *stream; track = audiofile->tracks; }
The Rest of the Input System will handle everything for playback of the MP2 File now.
Low Level : Opening an Input Device
When there is no interface present for the current playback of a sound(file) the developer may request an open RTMMM channel by calling the following routines (example code from a Module Player)
// // the only things the developer has to provide are // // md_mixfreq (44100 or 22050 or 11000) // number of channels used (1 or 2) // // the rest will be supplied by the rtmmm system // memman = Access_AudioStreamMemoryManager(50); RegisterOutputAudioStream(&FileORegistry); RegisterOutputAudioStream(&DARTRegistry); RegisterOutputAudioStream(&RTMMMRegistry); alloc_f = (md_mixfreq * AudioStreamPacketRefSize) / AudioStreamPacketRefFrequency; // up to 32767 so must be a multiple of 4 alloc_f &= 0x7ffc; alloc_header = alloc_f; if (channels == 2) alloc_header |= 0x20000; alloc_header |= 0x10000; allocator = memman->GetAllocator(alloc_header); buffer_free = alloc_f * 2; if (channels == 2) buffer_free *= 2; if (stream == NULL) { stream = OutputAudioStreamCreate("RTMMM"); stream->SetSourceName("MOD-PLAYER"); stream->SetSongName("MOD"); queue = stream->inqueue; queue->Access(); }
packet = allocator->GetPacket(); buffer = (int16 *)&packet->data; // // write a packet of data // the developer will here write a packet of the data created // VC_WriteBytes((char *)buffer,buffer_free ); queue->ReturnPacket(packet);
delete stream; memman->ReturnAllocator(allocator); Abbandon_AudioStreamMemoryManager(memman);
High Level : Opening an Output Device
In the following example, the RTMMM System will be setup for Output
if (streamn == 0) { stream[0] = OutputAudioStreamCreate("(chans=2,f=44100)RTMMM"); stream[0]->SetSourceName("My Player"); stream[0]->SetSongName("My Song Nane"); }Low Level : Requesting the Volume of a Specific Channel
memman->Lock(); core = (RTMMMAudioCore *)memman->global.RTMMM; if (core != NULL) { memcpy(&CopyCore,core,sizeof(CopyCore)); rc = DosOpenEventSem(NULL,&CopyCore.eventsem); memman->UnLock(); // getting the volume for selected channel vol = CopyCore.users[selected].volume; }else memman->UnLock();Low Level : Setting the Volume of a Specific Channel
memman->Lock(); core = (RTMMMAudioCore *)memman->global.RTMMM; if (core != NULL) { core->users[selected].volume += 500; if (core->users[selected].volume >= 32767) core->users[selected].volume = 32767; } memman->UnLock();