author | peter1138 |
Sun, 03 Aug 2008 17:35:08 +0000 | |
changeset 9834 | 7474149531c1 |
parent 9111 | 48ce04029fe4 |
permissions | -rw-r--r-- |
6072
2eb3e6ecba20
(svn r8805) -Codechange (r8757): DO set eol-style and keywords on new files...
Darkvater
parents:
6034
diff
changeset
|
1 |
/* $Id$ */ |
6034
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
2 |
|
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
8278
diff
changeset
|
3 |
/** @file libtimidity.cpp Playing music via the timidity library. */ |
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
8278
diff
changeset
|
4 |
|
6034
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
5 |
#include "../stdafx.h" |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
6 |
#include "../openttd.h" |
8278
99fd64ba8f1c
(svn r11842) -Fix: libtimidity.cpp did not compile anymore.
rubidium
parents:
8214
diff
changeset
|
7 |
#include "../sound_type.h" |
6034
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
8 |
#include "../variables.h" |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
9 |
#include "../debug.h" |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
10 |
#include "libtimidity.h" |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
11 |
#include <fcntl.h> |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
12 |
#include <sys/types.h> |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
13 |
#include <sys/wait.h> |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
14 |
#include <unistd.h> |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
15 |
#include <signal.h> |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
16 |
#include <sys/stat.h> |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
17 |
#include <errno.h> |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
18 |
#include <timidity.h> |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
19 |
#if defined(PSP) |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
20 |
#include <pspaudiolib.h> |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
21 |
#endif /* PSP */ |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
22 |
|
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
23 |
enum MidiState { |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
24 |
MIDI_STOPPED = 0, |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
25 |
MIDI_PLAYING = 1, |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
26 |
}; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
27 |
|
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
28 |
static struct { |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
29 |
MidIStream *stream; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
30 |
MidSongOptions options; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
31 |
MidSong *song; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
32 |
|
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
33 |
MidiState status; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
34 |
uint32 song_length; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
35 |
uint32 song_position; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
36 |
} _midi; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
37 |
|
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
38 |
#if defined(PSP) |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
39 |
static void AudioOutCallback(void *buf, unsigned int _reqn, void *userdata) |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
40 |
{ |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
41 |
memset(buf, 0, _reqn * PSP_NUM_AUDIO_CHANNELS); |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
42 |
if (_midi.status == MIDI_PLAYING) { |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
43 |
mid_song_read_wave(_midi.song, buf, _reqn * PSP_NUM_AUDIO_CHANNELS); |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
44 |
} |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
45 |
} |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
46 |
#endif /* PSP */ |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
47 |
|
7170
923946ec324f
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
6247
diff
changeset
|
48 |
static FMusicDriver_LibTimidity iFMusicDriver_LibTimidity; |
923946ec324f
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
6247
diff
changeset
|
49 |
|
923946ec324f
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
6247
diff
changeset
|
50 |
const char *MusicDriver_LibTimidity::Start(const char *const *param) |
6034
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
51 |
{ |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
52 |
_midi.status = MIDI_STOPPED; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
53 |
|
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
54 |
if (mid_init(param == NULL ? NULL : (char *)param[0]) < 0) { |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
55 |
/* If init fails, it can be because no configuration was found. |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
56 |
* If it was not forced via param, try to load it without a |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
57 |
* configuration. Who knows that works. */ |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
58 |
if (param != NULL || mid_init_no_config() < 0) { |
7170
923946ec324f
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
6247
diff
changeset
|
59 |
return "error initializing timidity"; |
6034
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
60 |
} |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
61 |
} |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
62 |
DEBUG(driver, 1, "successfully initialised timidity"); |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
63 |
|
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
64 |
_midi.options.rate = 44100; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
65 |
_midi.options.format = MID_AUDIO_S16LSB; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
66 |
_midi.options.channels = 2; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
67 |
#if defined(PSP) |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
68 |
_midi.options.buffer_size = PSP_NUM_AUDIO_SAMPLES; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
69 |
#else |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
70 |
_midi.options.buffer_size = _midi.options.rate; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
71 |
#endif |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
72 |
|
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
73 |
#if defined(PSP) |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
74 |
pspAudioInit(); |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
75 |
pspAudioSetChannelCallback(_midi.options.channels, &AudioOutCallback, NULL); |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
76 |
pspAudioSetVolume(_midi.options.channels, PSP_VOLUME_MAX, PSP_VOLUME_MAX); |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
77 |
#endif /* PSP */ |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
78 |
|
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
79 |
return NULL; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
80 |
} |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
81 |
|
7170
923946ec324f
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
6247
diff
changeset
|
82 |
void MusicDriver_LibTimidity::Stop() |
6034
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
83 |
{ |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
84 |
if (_midi.status == MIDI_PLAYING) { |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
85 |
_midi.status = MIDI_STOPPED; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
86 |
mid_song_free(_midi.song); |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
87 |
} |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
88 |
mid_exit(); |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
89 |
} |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
90 |
|
7170
923946ec324f
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
6247
diff
changeset
|
91 |
void MusicDriver_LibTimidity::PlaySong(const char *filename) |
6034
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
92 |
{ |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
93 |
_midi.stream = mid_istream_open_file(filename); |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
94 |
if (_midi.stream == NULL) { |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
95 |
DEBUG(driver, 0, "Could not open music file"); |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
96 |
return; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
97 |
} |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
98 |
|
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
99 |
_midi.song = mid_song_load(_midi.stream, &_midi.options); |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
100 |
mid_istream_close(_midi.stream); |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
101 |
_midi.song_length = mid_song_get_total_time(_midi.song); |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
102 |
|
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
103 |
if (_midi.song == NULL) { |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
104 |
DEBUG(driver, 1, "Invalid MIDI file"); |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
105 |
return; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
106 |
} |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
107 |
|
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
108 |
mid_song_start(_midi.song); |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
109 |
_midi.status = MIDI_PLAYING; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
110 |
} |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
111 |
|
7170
923946ec324f
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
6247
diff
changeset
|
112 |
void MusicDriver_LibTimidity::StopSong() |
6034
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
113 |
{ |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
114 |
_midi.status = MIDI_STOPPED; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
115 |
mid_song_free(_midi.song); |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
116 |
} |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
117 |
|
7170
923946ec324f
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
6247
diff
changeset
|
118 |
bool MusicDriver_LibTimidity::IsSongPlaying() |
6034
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
119 |
{ |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
120 |
if (_midi.status == MIDI_PLAYING) { |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
121 |
_midi.song_position = mid_song_get_time(_midi.song); |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
122 |
if (_midi.song_position >= _midi.song_length) { |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
123 |
_midi.status = MIDI_STOPPED; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
124 |
_midi.song_position = 0; |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
125 |
} |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
126 |
} |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
127 |
|
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
128 |
return (_midi.status == MIDI_PLAYING); |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
129 |
} |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
130 |
|
7170
923946ec324f
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
6247
diff
changeset
|
131 |
void MusicDriver_LibTimidity::SetVolume(byte vol) |
6034
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
132 |
{ |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
133 |
if (_midi.song != NULL) |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
134 |
mid_song_set_volume(_midi.song, vol); |
7a125490f55c
(svn r8757) -Add: added libtimidity music driver (it is a nice small library simular to timidity via extmidi)
truelight
parents:
diff
changeset
|
135 |
} |