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