1 /* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #include "ags/shared/util/wgt2_allg.h"
24 #include "ags/engine/media/audio/clip_my_midi.h"
25 #include "ags/ags.h"
26 #include "ags/music.h"
27
28 namespace AGS3 {
29
MYMIDI(Common::SeekableReadStream * data,bool repeat)30 MYMIDI::MYMIDI(Common::SeekableReadStream *data, bool repeat) :
31 _state(SoundClipInitial), _data(data), lengthInSeconds(0) {
32 _mixer = ::AGS::g_vm->_mixer;
33 _repeat = repeat;
34 }
35
destroy()36 void MYMIDI::destroy() {
37 ::AGS::g_music->stop();
38 delete _data;
39 _data = nullptr;
40 }
41
poll()42 void MYMIDI::poll() {
43 bool playing = is_playing();
44 if (playing)
45 _state = SoundClipPlaying;
46 else if (_state == SoundClipPlaying)
47 _state = SoundClipStopped;
48 }
49
seek(int pos)50 void MYMIDI::seek(int pos) {
51 warning("TODO: MYMIDI::seek");
52 }
53
get_pos()54 int MYMIDI::get_pos() {
55 // We don't know ms with midi
56 return 0;
57 }
58
get_pos_ms()59 int MYMIDI::get_pos_ms() {
60 // We don't know ms with midi
61 return 0;
62 }
63
get_length_ms()64 int MYMIDI::get_length_ms() {
65 warning("TODO: MYMIDI::get_length_ms");
66 return lengthInSeconds * 1000;
67 }
68
pause()69 void MYMIDI::pause() {
70 ::AGS::g_music->pause();
71 _state = SoundClipPaused;
72 }
73
resume()74 void MYMIDI::resume() {
75 if (_state != SoundClipPaused)
76 return;
77
78 ::AGS::g_music->resume();
79 _state = SoundClipPlaying;
80 }
81
play()82 int MYMIDI::play() {
83 ::AGS::g_music->playMusic(_data, _repeat);
84 _state = SoundClipPlaying;
85 return 1;
86 }
87
play_from(int position)88 int MYMIDI::play_from(int position) {
89 // TODO: Implement playing from arbitrary positions
90 if (position == 0) {
91 play();
92 return 1;
93 } else {
94 return 0;
95 }
96 }
97
is_playing() const98 bool MYMIDI::is_playing() const {
99 return ::AGS::g_music->isPlaying();
100 }
101
set_volume(int volume)102 void MYMIDI::set_volume(int volume) {
103 _vol = volume;
104 _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, volume);
105 }
106
set_panning(int newPanning)107 void MYMIDI::set_panning(int newPanning) {
108 // No implementation for MIDI
109 }
110
set_speed(int new_speed)111 void MYMIDI::set_speed(int new_speed) {
112 warning("TODO: MYMIDI::set_speed");
113 _speed = new_speed;
114 }
115
adjust_volume()116 void MYMIDI::adjust_volume() {
117 // TODO: See if this method is needed
118 }
119
120 } // namespace AGS3
121