author | Dennis Menschel <demichan at mail dot upb dot de> | 2009-03-20 23:23:05 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2009-03-22 17:15:32 (UTC) |
commit | 87cbeba4a750b1747dd32538c9c220145169cd2c (patch) (unidiff) | |
tree | 7953a6715c8ca0810cfaef4e1939fe2be534de3f /lib | |
parent | 0c21a7a0d5b84dc6726462f0fbe51b8c32433262 (diff) | |
download | midillo-master.zip midillo-master.tar.gz midillo-master.tar.bz2 |
Added missing includes <cstring> and <cassert>, which are
required/enforced by GCC 4.3.
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | lib/SMF.cc | 1 | ||||
-rw-r--r-- | lib/message.cc | 1 |
2 files changed, 2 insertions, 0 deletions
@@ -1,52 +1,53 @@ | |||
1 | #include <iostream> | 1 | #include <iostream> |
2 | #include <fstream> | 2 | #include <fstream> |
3 | #include <algorithm> | 3 | #include <algorithm> |
4 | #include <iterator> | 4 | #include <iterator> |
5 | #include <cstring> | ||
5 | #include <midillo/SMF.h> | 6 | #include <midillo/SMF.h> |
6 | 7 | ||
7 | namespace midillo { | 8 | namespace midillo { |
8 | using std::ifstream; | 9 | using std::ifstream; |
9 | using std::ofstream; | 10 | using std::ofstream; |
10 | using std::cin; | 11 | using std::cin; |
11 | using std::cout; | 12 | using std::cout; |
12 | using std::copy; | 13 | using std::copy; |
13 | using std::ostream_iterator; | 14 | using std::ostream_iterator; |
14 | using std::endl; | 15 | using std::endl; |
15 | 16 | ||
16 | void SMF_t::load(const char *f,bool stdinable) { | 17 | void SMF_t::load(const char *f,bool stdinable) { |
17 | if(stdinable && !strcmp(f,"-")) { | 18 | if(stdinable && !strcmp(f,"-")) { |
18 | load(cin); | 19 | load(cin); |
19 | }else{ | 20 | }else{ |
20 | ifstream s(f,std::ios::in|std::ios::binary); | 21 | ifstream s(f,std::ios::in|std::ios::binary); |
21 | load(s); | 22 | load(s); |
22 | } | 23 | } |
23 | } | 24 | } |
24 | 25 | ||
25 | void SMF_t::load(istream& s) { | 26 | void SMF_t::load(istream& s) { |
26 | mthd.load(s); | 27 | mthd.load(s); |
27 | tracks.resize(mthd.ntracks); | 28 | tracks.resize(mthd.ntracks); |
28 | tracks_t::iterator i = tracks.begin(); | 29 | tracks_t::iterator i = tracks.begin(); |
29 | for(int t=0;t<mthd.ntracks;++t,++i) { | 30 | for(int t=0;t<mthd.ntracks;++t,++i) { |
30 | i->load(s); | 31 | i->load(s); |
31 | } | 32 | } |
32 | } | 33 | } |
33 | 34 | ||
34 | void SMF_t::save(const char *f,bool stdoutable) const { | 35 | void SMF_t::save(const char *f,bool stdoutable) const { |
35 | if(stdoutable && !strcmp(f,"-")) { | 36 | if(stdoutable && !strcmp(f,"-")) { |
36 | save(cout); | 37 | save(cout); |
37 | }else{ | 38 | }else{ |
38 | ofstream s(f,std::ios::out|std::ios::trunc|std::ios::binary); | 39 | ofstream s(f,std::ios::out|std::ios::trunc|std::ios::binary); |
39 | save(s); | 40 | save(s); |
40 | } | 41 | } |
41 | } | 42 | } |
42 | 43 | ||
43 | void SMF_t::save(ostream& s) const { | 44 | void SMF_t::save(ostream& s) const { |
44 | mthd.save(s); | 45 | mthd.save(s); |
45 | for(tracks_t::const_iterator i=tracks.begin();i!=tracks.end();++i) { | 46 | for(tracks_t::const_iterator i=tracks.begin();i!=tracks.end();++i) { |
46 | i->save(s); | 47 | i->save(s); |
47 | } | 48 | } |
48 | } | 49 | } |
49 | 50 | ||
50 | void SMF_t::dump(ostream& s) const { | 51 | void SMF_t::dump(ostream& s) const { |
51 | std::ios::fmtflags ff = s.flags(); | 52 | std::ios::fmtflags ff = s.flags(); |
52 | s.unsetf(std::ios::hex); s.setf(std::ios::dec); | 53 | s.unsetf(std::ios::hex); s.setf(std::ios::dec); |
diff --git a/lib/message.cc b/lib/message.cc index 8f9e68a..6a5cfd6 100644 --- a/lib/message.cc +++ b/lib/message.cc | |||
@@ -1,50 +1,51 @@ | |||
1 | #include <algorithm> | 1 | #include <algorithm> |
2 | #include <iterator> | 2 | #include <iterator> |
3 | #include <cassert> | ||
3 | #include <midillo/message.h> | 4 | #include <midillo/message.h> |
4 | #include <midillo/util.h> | 5 | #include <midillo/util.h> |
5 | #include <midillo/exception.h> | 6 | #include <midillo/exception.h> |
6 | 7 | ||
7 | namespace midillo { | 8 | namespace midillo { |
8 | using std::copy; | 9 | using std::copy; |
9 | using std::ostream_iterator; | 10 | using std::ostream_iterator; |
10 | 11 | ||
11 | unsigned long message_t::calculate_save_size(int& rs) const { | 12 | unsigned long message_t::calculate_save_size(int& rs) const { |
12 | unsigned long rv = 0; | 13 | unsigned long rv = 0; |
13 | if(status!=rs) { | 14 | if(status!=rs) { |
14 | ++rv; | 15 | ++rv; |
15 | rs = status; | 16 | rs = status; |
16 | }else if((status&status_event_bits)==status_system) { | 17 | }else if((status&status_event_bits)==status_system) { |
17 | rs = -1; | 18 | rs = -1; |
18 | ++rv; // XXX: is it really needed? | 19 | ++rv; // XXX: is it really needed? |
19 | } | 20 | } |
20 | switch(status&status_event_bits) { | 21 | switch(status&status_event_bits) { |
21 | case status_note_off: | 22 | case status_note_off: |
22 | case status_note_on: | 23 | case status_note_on: |
23 | case status_polyphonic_key_pressure: // aka status_aftertouch | 24 | case status_polyphonic_key_pressure: // aka status_aftertouch |
24 | case status_control_change: | 25 | case status_control_change: |
25 | case status_pitch_wheel_change: | 26 | case status_pitch_wheel_change: |
26 | rv += 2; break; | 27 | rv += 2; break; |
27 | case status_program_change: | 28 | case status_program_change: |
28 | case status_channel_pressure: | 29 | case status_channel_pressure: |
29 | ++rv; break; | 30 | ++rv; break; |
30 | case status_system: | 31 | case status_system: |
31 | switch(status&status_system_bits) { | 32 | switch(status&status_system_bits) { |
32 | case status_system_sysex: | 33 | case status_system_sysex: |
33 | case status_system_end_of_sysex: | 34 | case status_system_end_of_sysex: |
34 | rv += data.size()+1; break; | 35 | rv += data.size()+1; break; |
35 | case status_system_MTC_quarter_frame: | 36 | case status_system_MTC_quarter_frame: |
36 | case status_system_song_select: | 37 | case status_system_song_select: |
37 | ++rv; break; | 38 | ++rv; break; |
38 | case status_system_song_position_pointer: | 39 | case status_system_song_position_pointer: |
39 | rv += 2; break; | 40 | rv += 2; break; |
40 | case status_system_tune_request: | 41 | case status_system_tune_request: |
41 | case status_system_timing_clock: // aka status_system_midi_clock | 42 | case status_system_timing_clock: // aka status_system_midi_clock |
42 | case status_system_midi_tick: | 43 | case status_system_midi_tick: |
43 | case status_system_start: // aka status_system_midi_start | 44 | case status_system_start: // aka status_system_midi_start |
44 | case status_system_stop: // aka status_system_midi_stop | 45 | case status_system_stop: // aka status_system_midi_stop |
45 | case status_system_continue: // aka status_system_midi_continue | 46 | case status_system_continue: // aka status_system_midi_continue |
46 | case status_system_active_sense: | 47 | case status_system_active_sense: |
47 | break; /* XXX: ensure there is no data? */ | 48 | break; /* XXX: ensure there is no data? */ |
48 | case status_system_meta: // also reset, but not for the purpose of midi file | 49 | case status_system_meta: // also reset, but not for the purpose of midi file |
49 | ++rv; | 50 | ++rv; |
50 | rv += calcVLsize(data.size()); | 51 | rv += calcVLsize(data.size()); |