1/*
2
3main.cpp
4
5Copyright (c) 2002 OpenBeOS.
6
7Author:
8	Michael Pfeiffer
9
10Permission is hereby granted, free of charge, to any person obtaining a copy of
11this software and associated documentation files (the "Software"), to deal in
12the Software without restriction, including without limitation the rights to
13use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
14of the Software, and to permit persons to whom the Software is furnished to do
15so, subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26THE SOFTWARE.
27
28*/
29
30#include "SynthFileReader.h"
31#include "SynthFile.h"
32#include <stdlib.h>
33#include <Application.h>
34
35
36void start_be_app() {
37	new BApplication("application/x.vnd-synth-file-reader");
38}
39
40int main(int argc, char* argv[]) {
41	if (argc < 2) {
42		printf("%s <synth file> [play [instr] | dump]\n", argv[0]);
43		return -1;
44	}
45	const char* fileName = argv[1];
46	bool        play     = argc >= 3 ? strcmp(argv[2], "play") == 0 : false;
47	bool        dump     = argc >= 3 ? strcmp(argv[2], "dump") == 0 : false;
48	uint32      instr    = argc >= 4 ? atol(argv[3]) : 0xffff;
49
50	if (dump) {
51		SSynthFile synth(fileName);
52		if (synth.InitCheck() == B_OK) {
53			synth.Dump();
54		}
55	} else {
56		SSynthFileReader reader(fileName);
57		if (reader.InitCheck() == B_OK) {
58			start_be_app();
59			reader.Dump(play, instr);
60		} else {
61			printf("could not open '%s' or not a valid synth file!\n", fileName);
62		}
63	}
64}
65