summaryrefslogtreecommitdiff
path: root/note_compiler/note.cpp.todo
blob: a256525c1788b68f09fe4d77651dce4a04119baa (plain)
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
void Note::set_param(const parameter_t &p, fixed_t v) //ACHTUNG:
{ 
	//wenn das verändert wird, muss auch program_t::set_param verändert werden!
	switch(p.par)
	{
		case ATTACK: envelope[p.osc]->set_attack(v*samp_rate >>SCALE); break;
		case DECAY: envelope[p.osc]->set_decay(v*samp_rate >>SCALE); break;
		case SUSTAIN: envelope[p.osc]->set_sustain(v); break;
		case RELEASE: envelope[p.osc]->set_release(v*samp_rate >>SCALE); break;
		case HOLD: envelope[p.osc]->set_hold(v!=0); break;

		case KSR: oscillator[p.osc].ksr=float(v)/ONE; break;
		case KSL: oscillator[p.osc].ksl=float(v)/ONE; break;

		case FACTOR: oscillator[p.osc].factor=v; break;
		case MODULATION: oscillator[p.osc].fm_strength[p.index]=v*pfactor.fm[p.osc][p.index] >>SCALE; break;
		case OUTPUT: oscillator[p.osc].output=v*pfactor.out[p.osc] >>SCALE; break;
		case TREMOLO: oscillator[p.osc].tremolo_depth=v; break;
		case TREM_LFO: oscillator[p.osc].tremolo_lfo=v; break;
		case VIBRATO: oscillator[p.osc].vibrato_depth=v; break;
		case VIB_LFO: oscillator[p.osc].vibrato_lfo=v; break;
		case WAVEFORM: oscillator[p.osc].waveform=v; break;
		case SYNC: oscillator[p.osc].sync=(v!=0); break;

		case FILTER_ENABLED: output_note("NOTE: cannot enable filter in playing notes"); break;
		case FILTER_ENV_AMOUNT: filter_params.env_amount=float(v*pfactor.filter_env)/ONE/ONE; break;

		case FILTER_ATTACK:
			if (filter_params.enabled)
				filter_envelope->set_attack(v*samp_rate/filter_update_frames >>SCALE);
			else
				output_note("NOTE: cannot set filter-attack when filter is disabled");
			break;

		case FILTER_DECAY:
			if (filter_params.enabled)
				filter_envelope->set_decay(v*samp_rate/filter_update_frames >>SCALE);
			else
				output_note("NOTE: cannot set filter-decay when filter is disabled");
			break;

		case FILTER_SUSTAIN:
			if (filter_params.enabled)
				filter_envelope->set_sustain(v);
			else
				output_note("NOTE: cannot set filter-sustain when filter is disabled");
			break;

		case FILTER_RELEASE:
			if (filter_params.enabled)
				filter_envelope->set_release(v*samp_rate/filter_update_frames >>SCALE);
			else
				output_note("NOTE: cannot set filter-release when filter is disabled");
			break;

		case FILTER_HOLD:
			if (filter_params.enabled)
				filter_envelope->set_hold(v!=0);
			else
				output_note("NOTE: cannot set filter-hold when filter is disabled");
			break;

		case FILTER_OFFSET: filter_params.freqfactor_offset=float(v*pfactor.filter_offset)/ONE/ONE; break;
		case FILTER_RESONANCE: filter_params.resonance=float(v*pfactor.filter_res)/ONE/ONE; break;
		case FILTER_TREMOLO: filter_params.trem_strength=v; break;
		case FILTER_TREM_LFO: filter_params.trem_lfo=v; break;
		
		case SYNC_FACTOR: sync_factor=v; break;
		default: throw string("trying to set an unknown parameter");

	}
}