be_midi.cc

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2000  Willem Jan Palenstijn
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 */
00018 
00019 #ifdef HAVE_CONFIG_H
00020 #  include <config.h>
00021 #endif
00022 
00023 //BEOS-specific code
00024 #ifdef BEOS
00025 
00026 #include "be_midi.h"
00027 #include "fnames.h"
00028 
00029 #include <string.h>
00030 #include <stdio.h>
00031 
00032 Be_midi::Be_midi()
00033 {
00034   FileOpen = false;
00035 }
00036 
00037 void Be_midi::stop_track(void)
00038 {
00039   if (FileOpen) {
00040     midiSynthFile.UnloadFile();
00041     FileOpen = false;
00042   }
00043 }
00044 
00045 Be_midi::~Be_midi(void)
00046 {
00047   stop_track();
00048 }
00049 
00050 bool  Be_midi::is_playing(void)
00051 {
00052   if (!FileOpen)
00053     return false;
00054 
00055   return !midiSynthFile.IsFinished();
00056 }
00057 
00058 
00059 void Be_midi::start_track(XMIDIEventList *event_list,bool repeat)
00060 {
00061   const char *name = MIDITMPFILE;
00062   event_list->Write(name);
00063 
00064 #if DEBUG
00065   cerr << "Stopping any running track" << endl;
00066 #endif
00067   stop_track();
00068 
00069 #if DEBUG
00070   cerr << "Starting midi sequence with Be_midi, repeat = " 
00071        << (repeat?"true":"false") << endl;
00072 #endif
00073 
00074   //open file
00075   get_ref_for_path(name, &midiRef);
00076   midiSynthFile.LoadFile(&midiRef);
00077   FileOpen = true;
00078 
00079   //set repeating
00080   midiSynthFile.EnableLooping(repeat);
00081 
00082   //play file
00083   midiSynthFile.Start();
00084 }
00085 
00086 const char *Be_midi::copyright(void)
00087 {
00088   return "Internal BeOS MIDI player";
00089 }
00090 
00091 
00092 #endif

Generated on Mon Jul 9 14:42:40 2007 for ExultEngine by  doxygen 1.5.1