This note is for code inside of Cognipilot, and should be considered more advanced. It is included here only for reference.
import numpy as np
def create_sound(tone_name, freq_max, freq_min, duration_sec, num_phases, steps):
print('struct tones_t {:s}[] = {{'.format(tone_name))
amp = (freq_max-freq_min)/2
for i in np.linspace(0, duration_sec, num=steps, endpoint=True):
note = freq_min+amp*(1+np.sin(np.pi*(num_phases/duration_sec)*i))
note_str = ' {{ .note = {:d}, .duration = {:d} }},'.format(int(note), int((duration_sec/steps)*1000))
print(note_str)
print(' { .note = REST, .duration = whole },')
print('};')
create_sound('b3rb_reject_tone', 2500, 150, .75, 2.5, 60)
struct tones_t b3rb_reject_tone[] = {
{ .note = 110, .duration = half },
{ .note = REST, .duration = thrirtysecond },