Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

SID_Be.i

Go to the documentation of this file.
00001 /*
00002  *  SID_Be.i - 6581 emulation, Be specific stuff
00003  *
00004  *  Frodo (C) 1994-1997 Christian Bauer
00005  */
00006 
00007 #include <MediaKit.h>
00008 
00009 #include "C64.h"
00010 
00011 
00012 /*
00013  *  Initialization, open subscriber
00014  */
00015 
00016 void DigitalRenderer::init_sound(void)
00017 {
00018         in_stream = false;
00019 
00020         the_stream = new BDACStream();
00021         the_sub = new BSubscriber("Frodo SID emulation");
00022         ready = the_sub->Subscribe(the_stream) == B_NO_ERROR;
00023         if (ready) {
00024                 the_stream->SetSamplingRate(SAMPLE_FREQ);
00025                 the_stream->SetStreamBuffers(SAMPLE_FREQ / CALC_FREQ * 4, 4);   // Must be called after EnterStream()
00026                 the_sub->EnterStream(NULL, true, this, stream_func, NULL, true);
00027                 in_stream = true;
00028         }
00029 }
00030 
00031 
00032 /*
00033  *  Destructor, close subscriber
00034  */
00035 
00036 DigitalRenderer::~DigitalRenderer()
00037 {
00038         if (ready) {
00039                 if (in_stream) {
00040                         the_sub->ExitStream(true);
00041                         in_stream = false;
00042                 }
00043                 the_stream->SetStreamBuffers(4096, 8);
00044                 the_sub->Unsubscribe();
00045                 ready = false;
00046         }
00047         delete the_sub;
00048         delete the_stream;
00049 }
00050 
00051 
00052 /*
00053  *  Sample volume (for sampled voice)
00054  */
00055 
00056 void DigitalRenderer::EmulateLine(void)
00057 {
00058         sample_buf[sample_in_ptr] = volume;
00059         sample_in_ptr = (sample_in_ptr + 1) % SAMPLE_BUF_SIZE;
00060 }
00061 
00062 
00063 /*
00064  *  Pause sound output
00065  */
00066 
00067 void DigitalRenderer::Pause(void)
00068 {
00069         if (in_stream) {
00070                 the_sub->ExitStream(true);
00071                 in_stream = false;
00072         }
00073 }
00074 
00075 
00076 /*
00077  *  Resume sound output
00078  */
00079 
00080 void DigitalRenderer::Resume(void)
00081 {
00082         if (!in_stream) {
00083                 the_sub->EnterStream(NULL, true, this, stream_func, NULL, true);
00084                 in_stream = true;
00085         }
00086 }
00087 
00088 
00089 /*
00090  *  Stream function 
00091  */
00092 
00093 bool DigitalRenderer::stream_func(void *arg, char *buf, size_t count, void *header)
00094 {
00095         ((DigitalRenderer *)arg)->calc_buffer((int16 *)buf, count);
00096         ((DigitalRenderer *)arg)->the_c64->SoundSync();
00097         return true;
00098 }

Generated on Tue Feb 8 04:08:10 2005 for E32frodo by doxygen 1.3.3