152a38012Sejakowatz /*
252a38012Sejakowatz
352a38012Sejakowatz main.cpp
452a38012Sejakowatz
5*2ca13760SColdfirex Copyright (c) 2002 Haiku.
652a38012Sejakowatz
752a38012Sejakowatz Author:
852a38012Sejakowatz Michael Pfeiffer
952a38012Sejakowatz
1052a38012Sejakowatz Permission is hereby granted, free of charge, to any person obtaining a copy of
1152a38012Sejakowatz this software and associated documentation files (the "Software"), to deal in
1252a38012Sejakowatz the Software without restriction, including without limitation the rights to
1352a38012Sejakowatz use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
1452a38012Sejakowatz of the Software, and to permit persons to whom the Software is furnished to do
1552a38012Sejakowatz so, subject to the following conditions:
1652a38012Sejakowatz
1752a38012Sejakowatz The above copyright notice and this permission notice shall be included in all
1852a38012Sejakowatz copies or substantial portions of the Software.
1952a38012Sejakowatz
2052a38012Sejakowatz THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2152a38012Sejakowatz IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2252a38012Sejakowatz FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2352a38012Sejakowatz AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2452a38012Sejakowatz LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2552a38012Sejakowatz OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2652a38012Sejakowatz THE SOFTWARE.
2752a38012Sejakowatz
2852a38012Sejakowatz */
2952a38012Sejakowatz
3052a38012Sejakowatz #include "SynthFileReader.h"
31bc962561SMichael Pfeiffer #include "SynthFile.h"
3252a38012Sejakowatz #include <stdlib.h>
3352a38012Sejakowatz #include <Application.h>
3452a38012Sejakowatz
3552a38012Sejakowatz
start_be_app()3652a38012Sejakowatz void start_be_app() {
3752a38012Sejakowatz new BApplication("application/x.vnd-synth-file-reader");
3852a38012Sejakowatz }
3952a38012Sejakowatz
main(int argc,char * argv[])4052a38012Sejakowatz int main(int argc, char* argv[]) {
4152a38012Sejakowatz if (argc < 2) {
42bc962561SMichael Pfeiffer printf("%s <synth file> [play [instr] | dump]\n", argv[0]);
4352a38012Sejakowatz return -1;
4452a38012Sejakowatz }
4552a38012Sejakowatz const char* fileName = argv[1];
4652a38012Sejakowatz bool play = argc >= 3 ? strcmp(argv[2], "play") == 0 : false;
47bc962561SMichael Pfeiffer bool dump = argc >= 3 ? strcmp(argv[2], "dump") == 0 : false;
4852a38012Sejakowatz uint32 instr = argc >= 4 ? atol(argv[3]) : 0xffff;
4952a38012Sejakowatz
50bc962561SMichael Pfeiffer if (dump) {
51bc962561SMichael Pfeiffer SSynthFile synth(fileName);
52bc962561SMichael Pfeiffer if (synth.InitCheck() == B_OK) {
53bc962561SMichael Pfeiffer synth.Dump();
54bc962561SMichael Pfeiffer }
55bc962561SMichael Pfeiffer } else {
56bc962561SMichael Pfeiffer SSynthFileReader reader(fileName);
57bc962561SMichael Pfeiffer if (reader.InitCheck() == B_OK) {
5852a38012Sejakowatz start_be_app();
5952a38012Sejakowatz reader.Dump(play, instr);
6052a38012Sejakowatz } else {
6152a38012Sejakowatz printf("could not open '%s' or not a valid synth file!\n", fileName);
6252a38012Sejakowatz }
6352a38012Sejakowatz }
64bc962561SMichael Pfeiffer }
65