Assorted whitespace cleanup and typo fixes.
[haiku.git] / src / kits / midi / MidiSynthFile.cpp
blob43e961d7905b74c924f41657dc0d01e95883bd71
1 /*
2 * Copyright 2006, Haiku.
4 * Copyright (c) 2002-2004 Matthijs Hollemans
5 * Copyright (c) 2003 Jerome Leveque
6 * Distributed under the terms of the MIT License.
8 * Authors:
9 *
10 * Matthijs Hollemans
11 * Jérôme Leveque
14 #include "debug.h"
15 #include <MidiStore.h>
16 #include <MidiSynthFile.h>
17 #include "SoftSynth.h"
19 using namespace BPrivate;
22 BMidiSynthFile::BMidiSynthFile()
24 fStore = new BMidiStore();
28 BMidiSynthFile::~BMidiSynthFile()
30 Stop();
31 delete fStore;
35 status_t
36 BMidiSynthFile::LoadFile(const entry_ref* midi_entry_ref)
38 if (midi_entry_ref == NULL)
39 return B_BAD_VALUE;
41 EnableInput(true, false);
42 fStore->fFinished = true;
44 status_t err = fStore->Import(midi_entry_ref);
46 if (err == B_OK) {
47 for (int t = 0; t < 128; ++t) {
48 if (fStore->fInstruments[t]) {
49 be_synth->fSynth->LoadInstrument(t);
54 return err;
58 void
59 BMidiSynthFile::UnloadFile(void)
61 delete fStore;
62 fStore = new BMidiStore();
66 status_t
67 BMidiSynthFile::Start(void)
69 fStore->Connect(this);
70 fStore->SetCurrentEvent(0);
71 return fStore->Start();
75 void
76 BMidiSynthFile::Stop(void)
78 fStore->Stop();
79 fStore->Disconnect(this);
83 void
84 BMidiSynthFile::Fade(void)
86 Stop(); // really quick fade :P
90 void
91 BMidiSynthFile::Pause(void)
93 fStore->fPaused = true;
97 void
98 BMidiSynthFile::Resume(void)
100 fStore->fPaused = false;
104 int32
105 BMidiSynthFile::Duration(void) const
107 return fStore->DeltaOfEvent(fStore->CountEvents());
111 int32
112 BMidiSynthFile::Position(int32 ticks) const
114 return fStore->EventAtDelta(ticks);
118 int32
119 BMidiSynthFile::Seek()
121 return fStore->CurrentEvent();
125 status_t
126 BMidiSynthFile::GetPatches(
127 int16* pArray768, int16* pReturnedCount) const
129 int16 count = 0;
131 for (int t = 0; t < 128; ++t) {
132 if (fStore->fInstruments[t]) {
133 pArray768[count++] = t;
137 *pReturnedCount = count;
138 return B_OK;
142 void
143 BMidiSynthFile::SetFileHook(synth_file_hook pSongHook, int32 arg)
145 fStore->fHookFunc = pSongHook;
146 fStore->fHookArg = arg;
150 bool
151 BMidiSynthFile::IsFinished() const
153 return fStore->fFinished;
157 void
158 BMidiSynthFile::ScaleTempoBy(double tempoFactor)
160 fStore->SetTempo((int32) (Tempo() * tempoFactor));
164 void
165 BMidiSynthFile::SetTempo(int32 newTempoBPM)
167 fStore->SetTempo(newTempoBPM);
171 int32
172 BMidiSynthFile::Tempo(void) const
174 return fStore->Tempo();
178 void
179 BMidiSynthFile::EnableLooping(bool loop)
181 fStore->fLooping = loop;
185 void
186 BMidiSynthFile::MuteTrack(int16 track, bool do_mute)
188 fprintf(stderr, "[midi] MuteTrack is broken; don't use it\n");
192 void
193 BMidiSynthFile::GetMuteMap(char* pTracks) const
195 fprintf(stderr, "[midi] GetMuteMap is broken; don't use it\n");
199 void
200 BMidiSynthFile::SoloTrack(int16 track, bool do_solo)
202 fprintf(stderr, "[midi] SoloTrack is broken; don't use it\n");
206 void
207 BMidiSynthFile::GetSoloMap(char* pTracks) const
209 fprintf(stderr, "[midi] GetSoloMap is broken; don't use it\n");
213 void BMidiSynthFile::_ReservedMidiSynthFile1() { }
214 void BMidiSynthFile::_ReservedMidiSynthFile2() { }
215 void BMidiSynthFile::_ReservedMidiSynthFile3() { }