Loading prj_c_04_instrument...
attack_duration: 0 decay_duration: 0.05 sustain_level: 0.7 release_duration: 0.25 6 overtones • freq_factor: 1 amplitude: 1 • freq_factor: 2 amplitude: 0.5 • freq_factor: 4 amplitude: 0.25 • freq_factor: 8 amplitude: 0.125 • freq_factor: 16 amplitude: 0.0625 • freq_factor: 32 amplitude: 0.03125
if note_duration < envelope_attack_duration: # the note stops during the attack phase attack_level = note_duration / envelope_attack_duration attack_duration = note_duration decay_duration = 0.0 sustain_level = attack_level elif note_duration < envelope_attack_duration + envelope_decay_duration # the note stops during the decay phase decay_duration = note_duration - envelope_attack_duration ratio = decay_duration / envelope_decay_duration sustain_level = 1.0 - (1.0 - envelope_sustain_level) * ratio attack_duration = envelope_attack_duration attack_level = 1.0 else: # the note lasts long enough attack_duration = envelope_attack_duration attack_level = 1.0 decay_duration = envelope_decay_duration sustain_level = envelope_sustain_level total_duration = note_duration + envelope_release_duration
attack_end = int(attack_duration * sample_rate) decay_end = int((attack_duration + decay_duration) * sample_rate) sustain_end = int(note_duration * sample_rate) total_end = int(total_duration * sample_rate) amplitudes = [0.0] * total_end dt = 1.0 / sample_rate for index in range(0, attack_end): # amplitudes during the attack phase time = index * dt amplitudes[index] = attack_level * time / attack_duration for index in range(attack_end, decay_end): # amplitudes during the decay phase time = index * dt ratio = (time - attack_duration) / decay_duration amplitudes[index] = attack_level - (attack_level - sustain_level) * ratio for index in range(decay_end, sustain_end): # amplitudes during the sustain phase amplitudes[index] = sustain_level for index in range(sustain_end, total_end): # amplitudes during the release phase time = index * dt ratio = (total_duration - time) / envelope_release_duration amplitudes[index] = sustain_level * ratio
attack_duration 0.01 decay_duration 1.00 sustain_level 0.00 release_duration 0.50 overtones 6 freq_factor 1.0 amplitude 0.10 freq_factor 2.0 amplitude 0.64 freq_factor 3.0 amplitude 0.11 freq_factor 4.0 amplitude 0.13 freq_factor 5.0 amplitude 0.01 freq_factor 6.0 amplitude 0.01
attack_duration 0.25 decay_duration 0.00 sustain_level 1.00 release_duration 0.50 overtones 10 freq_factor 1.0 amplitude 0.50 freq_factor 2.0 amplitude 0.15 freq_factor 3.0 amplitude 0.10 freq_factor 4.0 amplitude 0.07 freq_factor 5.0 amplitude 0.07 freq_factor 6.0 amplitude 0.04 freq_factor 7.0 amplitude 0.03 freq_factor 8.0 amplitude 0.02 freq_factor 9.0 amplitude 0.01 freq_factor 10.0 amplitude 0.01
attack_duration 0.10 decay_duration 0.10 sustain_level 0.90 release_duration 0.20 overtones 10 freq_factor 1.0 amplitude 1.00 freq_factor 2.0 amplitude 0.03 freq_factor 3.0 amplitude 0.58 freq_factor 4.0 amplitude 0.05 freq_factor 5.0 amplitude 0.26 freq_factor 6.0 amplitude 0.08 freq_factor 7.0 amplitude 0.01 freq_factor 8.0 amplitude 0.04 freq_factor 9.0 amplitude 0.01 freq_factor 10.0 amplitude 0.04
attack_duration 0.10 decay_duration 0.00 sustain_level 1.00 release_duration 0.10 overtones 10 freq_factor 1.0 amplitude 0.33 freq_factor 2.0 amplitude 0.33 freq_factor 3.0 amplitude 0.23 freq_factor 4.0 amplitude 0.23 freq_factor 5.0 amplitude 0.30 freq_factor 6.0 amplitude 0.06 freq_factor 7.0 amplitude 0.05 freq_factor 8.0 amplitude 0.02 freq_factor 9.0 amplitude 0.03 freq_factor 10.0 amplitude 0.02
attack_duration 0.00 decay_duration 0.05 sustain_level 0.70 release_duration 0.25 overtones 6 freq_factor 1.0 amplitude 1.0 freq_factor 2.0 amplitude 0.5 freq_factor 4.0 amplitude 0.25 freq_factor 8.0 amplitude 0.125 freq_factor 16.0 amplitude 0.0625 freq_factor 32.0 amplitude 0.03125
attack_duration 0.01 decay_duration 2.00 sustain_level 0.00 release_duration 1.00 overtones 10 freq_factor 1.0 amplitude 0.11 freq_factor 2.0 amplitude 0.35 freq_factor 3.0 amplitude 0.10 freq_factor 4.0 amplitude 0.20 freq_factor 5.0 amplitude 0.07 freq_factor 6.0 amplitude 0.04 freq_factor 7.0 amplitude 0.05 freq_factor 8.0 amplitude 0.04 freq_factor 9.0 amplitude 0.01 freq_factor 10.0 amplitude 0.03
" attack_duration %lg" " decay_duration %lg" " sustain_level %lg" " release_duration %lg" " overtones %d "
./prog_note 220.0 data/cello.instrument
./prog_part 0.5 data/cello.instrument data/scale.part
frequency 65.41 amplitude 0.50 time 0.00 duration 0.25 frequency 73.42 amplitude 0.50 time 0.25 duration 0.25 frequency 82.41 amplitude 0.50 time 0.50 duration 0.25 frequency 87.31 amplitude 0.50 time 0.75 duration 0.25 frequency 98.00 amplitude 0.50 time 1.00 duration 0.25 frequency 110.00 amplitude 0.50 time 1.25 duration 0.25 frequency 123.47 amplitude 0.50 time 1.50 duration 0.25 frequency 130.81 amplitude 0.50 time 1.75 duration 0.25 frequency 146.83 amplitude 0.50 time 2.00 duration 0.25 frequency 164.81 amplitude 0.50 time 2.25 duration 0.25 frequency 174.61 amplitude 0.50 time 2.50 duration 0.25 frequency 196.00 amplitude 0.50 time 2.75 duration 0.25 frequency 220.00 amplitude 0.50 time 3.00 duration 0.25 frequency 246.94 amplitude 0.50 time 3.25 duration 0.25 frequency 261.63 amplitude 0.50 time 3.50 duration 0.25 frequency 293.66 amplitude 0.50 time 3.75 duration 0.25 frequency 329.63 amplitude 0.50 time 4.00 duration 0.25 frequency 349.23 amplitude 0.50 time 4.25 duration 0.25 frequency 392.00 amplitude 0.50 time 4.50 duration 0.25 frequency 440.00 amplitude 0.50 time 4.75 duration 0.25 frequency 493.88 amplitude 0.50 time 5.00 duration 0.25 frequency 523.25 amplitude 0.50 time 5.25 duration 0.25 frequency 196.00 amplitude 0.50 time 5.50 duration 0.50 frequency 246.94 amplitude 0.50 time 5.50 duration 0.50 frequency 293.66 amplitude 0.50 time 5.50 duration 0.50 frequency 130.81 amplitude 0.50 time 6.00 duration 1.00 frequency 164.81 amplitude 0.50 time 6.00 duration 1.00 frequency 196.00 amplitude 0.50 time 6.00 duration 1.00