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
// An example of a software synthesizer using the JACK back-end.
// The code that is shared between all backends is in the `test_synth.rs` file.
//
// Compiling
// =========
// You can compile this example with
// ```
// cargo build --release --examples --features backend-jack
// ```
// This generates a standalone application that you can find
//
// * in `target/release/examples/jack_synth` when you're using Linux
// * under the `target/release/examples/` folder when you're using Windows or MacOs
//
// Running
// =======
//
// In order to run, you need three steps. Below, we discuss for each platform
// (only Linux for now) how you can do this.
//
// 1. Start the `jack` daemon.
// 2. Start the application generated during compiling.
// 3. Connect the audio output of the synthesizer to the "system" audio input
// 4. (Optionally) start a midi keyboard simulator
// 5. Connect the midi keyboard output to the synthesizer midi input
// 6. Start making some noise!
//
// ## Running under Linux
// I think the easiest way is to use `qjackctl` and maybe `jack-keyboard`.
// Then the steps become
//
// 1. Start `qjackctl`. Optionally configure some stuff. Click the "start" button.
// 2. Start the synthesizer generated during compiling. This needs to be done after
// the jack daemon was started in step 1 because it automatically registers its ports upon
// startup.
// 3. In Qjackctl, click on the "Connect" button. Under the "Audio" tab, connect the
// synthesizer to the system.
// 4. (optionally) start `jack-keyboard`.
// 5. In Qjackctl, in the "Connections" window, under the "Midi" tab, connect the
// midi keyboard to the synthesizer.
// 6. Press keys on the midi keyboard.
//
// ## Logging
// In order to enable logging, set the environment variable `RSYNTH_LOG_LEVEL` to
// one of the supported log levels.
// Recognized log levels are: 'off', 'error', 'warning', 'info', 'debug' and 'trace'.
//
// You can set the environment variable `RSYNTH_LOG_FILE` to the file name of the file in which
// you want to log.
//
// Note that these environment variables need to be visible to the host.
// Note that the example is also logging to a file in the realtime thread, which may cause clipping.
extern crate log;
extern crate asprim;
extern crate num_traits;
extern crate rand;
extern crate rsynth;
use *;
use run;