1(INSTRSAX-COMPLETE-ALG
2(NAME "sax_all")
3(ARGUMENTS ("double" "freq") ("sound_type" "breath_env") ("sound_type" "freq_env")
4        ("double" "vibrato_freq") ("double" "vibrato_gain")
5	("sound_type" "reed_stiffness") ("sound_type" "noise_env")
6        ("sound_type" "blow_pos") ("sound_type" "reed_table_offset")
7        ("rate_type" "sr"))
8(STATE ("struct instr *" "sax" "initInstrument(SAXOFONY, ROUND32(sr));
9    noteOn(susp->sax, freq, 1.0);
10    controlChange(susp->sax, 29, SAX_CONTROL_CHANGE_CONST * vibrato_freq);
11    controlChange(susp->sax, 1, SAX_CONTROL_CHANGE_CONST * vibrato_gain);")
12       ("double" "frequency" "freq")
13       ("float" "breath_scale" "breath_env->scale * SAX_CONTROL_CHANGE_CONST")
14       ("float" "reed_scale" "reed_stiffness->scale * SAX_CONTROL_CHANGE_CONST")
15       ("float" "noise_scale" "noise_env->scale * SAX_CONTROL_CHANGE_CONST")
16       ("float" "blow_scale" "blow_pos->scale * SAX_CONTROL_CHANGE_CONST")
17       ("float" "offset_scale"
18        "reed_table_offset->scale * SAX_CONTROL_CHANGE_CONST"))
19
20(START (min breath_env))
21; matched doesn't help much because controlChange() is called in inner loop
22;(MATCHED-SAMPLE-RATE freq_env breath_env
23;                     reed_stiffness noise_env blow_pos reed_table_offset)
24(CONSTANT "frequency" "breath_scale" "reed_scale" "noise_scale"
25          "blow_scale" "offset_scale")
26(ALWAYS-SCALE freq_env)
27(INTERNAL-SCALING breath_env reed_stiffness noise_env
28                  blow_pos reed_table_offset)
29(INLINE-INTERPOLATION no)
30(SAMPLE-RATE "sr")
31(TERMINATE (min breath_env))
32(INNER-LOOP "controlChange(sax, 128, breath_scale * breath_env);
33            controlChange(sax, 2, reed_scale * reed_stiffness);
34            controlChange(sax, 4, noise_scale * noise_env);
35            controlChange(sax, 11, blow_scale * blow_pos);
36            controlChange(sax, 26, offset_scale * reed_table_offset);
37            setFrequency(sax, frequency + freq_env);
38            output = (sample_type) tick(sax)")
39(SUPPORT-HEADER "#define SAX_CONTROL_CHANGE_CONST 128\n")
40(SUPPORT-FUNCTIONS "#include \"instr.h\"\n#include \"upsample.h\"\n")
41(FINALIZATION "    deleteInstrument(susp->sax);\n")
42)
43
44