OpenTTD Source: src/music/bemidi.cpp Source File

OpenTTD Source 1.11.0-RC1

bemidi.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10 #include "../stdafx.h"
11 #include "../openttd.h"
12 #include "bemidi.h"
13 #include "../base_media_base.h"
14 #include "midifile.hpp"
15
16 /* BeOS System Includes */
17 #include <MidiSynthFile.h>
18
19 #include "../safeguards.h"
20
22 static BMidiSynthFile midiSynthFile;
23
25 static FMusicDriver_BeMidi iFMusicDriver_BeMidi;
26
27 const char *MusicDriver_BeMidi::Start(const StringList &parm)
28 {
29 return nullptr;
30 }
31
32 void MusicDriver_BeMidi::Stop()
33 {
34 midiSynthFile.UnloadFile();
35 }
36
37 void MusicDriver_BeMidi::PlaySong(const MusicSongInfo &song)
38 {
39 std::string filename = MidiFile::GetSMFFile(song);
40
41 this->Stop();
42 if (!filename.empty()) {
43 entry_ref midiRef;
44 get_ref_for_path(filename.c_str(), &midiRef);
45 midiSynthFile.LoadFile(&midiRef);
46 midiSynthFile.Start();
47 }
48 }
49
50 void MusicDriver_BeMidi::StopSong()
51 {
52 midiSynthFile.UnloadFile();
53 }
54
55 bool MusicDriver_BeMidi::IsSongPlaying()
56 {
57 return !midiSynthFile.IsFinished();
58 }
59
60 void MusicDriver_BeMidi::SetVolume(byte vol)
61 {
62 fprintf(stderr, "BeMidi: Set volume not implemented\n");
63 }
midiSynthFile
static BMidiSynthFile midiSynthFile
The file we're playing.
Definition: bemidi.cpp:22
iFMusicDriver_BeMidi
static FMusicDriver_BeMidi iFMusicDriver_BeMidi
Factory for BeOS' midi player.
Definition: bemidi.cpp:25
MusicDriver_BeMidi::StopSong
void StopSong() override
Stop playing the current song.
Definition: bemidi.cpp:50
MusicDriver_BeMidi::PlaySong
void PlaySong(const MusicSongInfo &song) override
Play a particular song.
Definition: bemidi.cpp:37
MusicSongInfo
Metadata about a music track.
Definition: base_media_base.h:291
StringList
std::vector< std::string > StringList
Type for a list of strings.
Definition: string_type.h:58
MidiFile::GetSMFFile
static std::string GetSMFFile(const MusicSongInfo &song)
Get the name of a Standard MIDI File for a given song.
Definition: midifile.cpp:1047
bemidi.h
MusicDriver_BeMidi::IsSongPlaying
bool IsSongPlaying() override
Are we currently playing a song?
Definition: bemidi.cpp:55
MusicDriver_BeMidi::Stop
void Stop() override
Stop this driver.
Definition: bemidi.cpp:32
FMusicDriver_BeMidi
Factory for the BeOS midi player.
Definition: bemidi.h:33
MusicDriver_BeMidi::SetVolume
void SetVolume(byte vol) override
Set the volume, if possible.
Definition: bemidi.cpp:60
MusicDriver_BeMidi::Start
const char * Start(const StringList &param) override
Start this driver.
Definition: bemidi.cpp:27