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.
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()
36 BMidiSynthFile::LoadFile(const entry_ref
* midi_entry_ref
)
38 if (midi_entry_ref
== NULL
)
41 EnableInput(true, false);
42 fStore
->fFinished
= true;
44 status_t err
= fStore
->Import(midi_entry_ref
);
47 for (int t
= 0; t
< 128; ++t
) {
48 if (fStore
->fInstruments
[t
]) {
49 be_synth
->fSynth
->LoadInstrument(t
);
59 BMidiSynthFile::UnloadFile(void)
62 fStore
= new BMidiStore();
67 BMidiSynthFile::Start(void)
69 fStore
->Connect(this);
70 fStore
->SetCurrentEvent(0);
71 return fStore
->Start();
76 BMidiSynthFile::Stop(void)
79 fStore
->Disconnect(this);
84 BMidiSynthFile::Fade(void)
86 Stop(); // really quick fade :P
91 BMidiSynthFile::Pause(void)
93 fStore
->fPaused
= true;
98 BMidiSynthFile::Resume(void)
100 fStore
->fPaused
= false;
105 BMidiSynthFile::Duration(void) const
107 return fStore
->DeltaOfEvent(fStore
->CountEvents());
112 BMidiSynthFile::Position(int32 ticks
) const
114 return fStore
->EventAtDelta(ticks
);
119 BMidiSynthFile::Seek()
121 return fStore
->CurrentEvent();
126 BMidiSynthFile::GetPatches(
127 int16
* pArray768
, int16
* pReturnedCount
) const
131 for (int t
= 0; t
< 128; ++t
) {
132 if (fStore
->fInstruments
[t
]) {
133 pArray768
[count
++] = t
;
137 *pReturnedCount
= count
;
143 BMidiSynthFile::SetFileHook(synth_file_hook pSongHook
, int32 arg
)
145 fStore
->fHookFunc
= pSongHook
;
146 fStore
->fHookArg
= arg
;
151 BMidiSynthFile::IsFinished() const
153 return fStore
->fFinished
;
158 BMidiSynthFile::ScaleTempoBy(double tempoFactor
)
160 fStore
->SetTempo((int32
) (Tempo() * tempoFactor
));
165 BMidiSynthFile::SetTempo(int32 newTempoBPM
)
167 fStore
->SetTempo(newTempoBPM
);
172 BMidiSynthFile::Tempo(void) const
174 return fStore
->Tempo();
179 BMidiSynthFile::EnableLooping(bool loop
)
181 fStore
->fLooping
= loop
;
186 BMidiSynthFile::MuteTrack(int16 track
, bool do_mute
)
188 fprintf(stderr
, "[midi] MuteTrack is broken; don't use it\n");
193 BMidiSynthFile::GetMuteMap(char* pTracks
) const
195 fprintf(stderr
, "[midi] GetMuteMap is broken; don't use it\n");
200 BMidiSynthFile::SoloTrack(int16 track
, bool do_solo
)
202 fprintf(stderr
, "[midi] SoloTrack is broken; don't use it\n");
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() { }