~kulthauskante/nsynth/devel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
 * nonlimitedSynth - Backend to reacTIVision
 *
 * Copyright (c) 2007-2008 Karsten Krispin
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */
 
 
#include "main.h"

#include "Configuration/Configuration.h"
#include "Configuration/Reader/XmlReader.h"

#include "Synth/SynthManager/SynthManager.h"

#include "Tangibles/Global/Sinks/SystemSink.h"
#include "Base/Metronome/GlobalMetronome.h"

#include "Synth/AudioBackends/PortAudioBackend.h"

#include "Helper/SoundFontPlayer.h"


//#include "Tangibles/Controller/Linear/Sequencer/Sequencer.h"
//#include "Tangibles/Audio/Generator/Generator.h"
//#include "Tangibles/Controller/Linear/LFOs/SinusController.h"

int main(int argn, char * argv[])
{

	QApplication app(argn, argv);
	QString configFilename = "nonlimitedSynth.xml";


	/* Do not ceate anything before configuration instance has been created.
		 Otherwise this application's behaviour is undefined. */
	Configuration appConfig;
	
	/* parse arguments */
	if(argn > 1)
	{
		QString arg1(argv[1]);
		if(arg1 == "-h" || arg1 == "--help")
		{
			std::cout << "nonlimitedSynth Help:" << std::endl;
			std::cout << "Synopsis:" << std::endl;
			std::cout << "  $ nSynth [--audio-devs | configFile.xml]" << std::endl;
			std::cout << "    --audio-devs: print a list of available devices" << std::endl;
			exit(0);
		}
		else if(arg1 == "--audio-devs")
		{
			PortAudioBackend::displayDevices();
			exit(0);
		}
		else
		{
			configFilename = QString(argv[1]);
		}
	}
	
	/* initialize configuration */
	XmlConfigurationReader xmlReader(configFilename);
	xmlReader.readIn(appConfig);
	

	SoundFontPlayer & sfPlayer = SoundFontPlayer::instance();

	/* setup the metronome */
	GlobalMetronome & metronome = GlobalMetronome::instance();	
	/* dirty hack */
	metronome.setBpm(90);
	/* Initialize master processing */
	SynthManager master;
	
	/* Insert the Main Sink which feeds the audio output */
	TangibleSynthProcessing * audioSink  = new SystemSink();
	master.insertChild(audioSink);
	audioSink->InitialUpdateTangibleInterface(0.5, 0.5, 0.0);
	

//	Sequencer * sequencer = new Sequencer(new TangibleConfiguration());
//	master.insertChild(sequencer);
//	sequencer->InitialUpdateTangibleInterface(0.3, 0.3, 0.5);
//	AudioGeneratorProcessing * generator = new AudioGeneratorProcessing(new TangibleConfiguration());
//	master.insertChild(generator);
//	generator->InitialUpdateTangibleInterface(0.4,0.4, 0.8);
//
//	SinusController * sinController = new SinusController(new TangibleConfiguration());
//	master.insertChild(sinController);
//	sinController->InitialUpdateTangibleInterface(0.3, 0.5, 0.3);

	qDebug() << "\n\n nonlimitedSynth started...\n";
	
	/* Run event loop */
	return app.exec();
}