2 * SysEx to SMF convertor
3 * Copyright © 2020 František Kučera (Frantovo.cz, GlobalCode.info)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 int main(int argc, char**argv) {
23 smf_t* smf = smf_new();
24 smf_track_t* track = smf_track_new();
25 smf_add_track(smf, track);
27 std::stringstream data;
28 for (char ch; std::cin.read(&ch, 1).good();) {
32 smf_event_t* event = smf_event_new_from_pointer((void*) data.str().c_str(), data.tellp());
33 smf_track_add_event_pulses(track, event, 0);
36 int res = smf_save(smf, argv[1]);
37 if (res) std::cerr << "unable to save MIDI file: " << res << std::endl;
40 std::cerr << "Usage: " << argv[0] << " 'output-file.mid'" << std::endl;