# make logarithmic spectral ripples form Enter parameters for spectral ripple real left_duration 0.5 real right_duration 0.5 real left_ripples_per_octave 2 real right_ripples_per_octave 4 real left_phase 0 real right_phase 0 real left_mod_depth 6 real right_mod_depth 6 real left_final_intensity 70 real right_final_intensity 70 comment final high-pass and low-pass settings real left_final_HP 1000 real right_final_HP 1000 real left_final_LP 8000 real right_final_LP 8000 boolean left_buffer_edges_with_noise no boolean right_buffer_edges_with_noise no optionmenu carrier 1 option use_noise option use_tone_complex real tc_F0 50 comment boolean view_after_creation yes real sampling_frequency 44100 endform #----------------------------------------------------# # constant variables left_final_skirt_low = left_final_HP/2 left_final_skirt_high = left_final_LP/2 right_final_skirt_low = right_final_HP/2 right_final_skirt_high = right_final_LP/2 ramp_duration = 0.03 silent_gap_duration = 0.3 log_start = 100 log2_freq_start = log2(log_start) log2_freq_offset = log2_freq_start-1 if carrier == 1 use_noise = 1 use_tone_complex = 0 elsif carrier == 2 use_tone_complex = 1 use_noise = 0 endif #----------------------------------------------------# call makeRipple left_duration left_ripples_per_octave left_phase left_mod_depth left_final_intensity left_final_HP left_final_LP left_final_skirt_low left_final_skirt_high left_buffer_edges_with_noise ramp_duration use_noise use_tone_complex tc_F0 firstRipple$ = "'finalName$'" call make_silence silent_gap_duration silence call makeRipple right_duration right_ripples_per_octave right_phase right_mod_depth right_final_intensity right_final_HP right_final_LP right_final_skirt_low right_final_skirt_high right_buffer_edges_with_noise ramp_duration use_noise use_tone_complex tc_F0 secondRipple$ = "'finalName$'" if view_after_creation = 1 select Sound 'firstRipple$' plus Sound silence plus Sound 'secondRipple$' Concatenate recoverably select Sound chain plus TextGrid chain View & Edit endif select Sound silence Remove procedure makeRipple .duration .ripples_per_octave .phase .mod_depth .final_intensity .final_HP .final_LP .final_skirt_low .final_skirt_high .buffer_edges_with_noise .ramp_duration .use_noise .use_tone_complex .tc_F0 # constants sampling_frequency = 44100 log_start = 100 log2_freq_start = log2(log_start) log2_freq_offset = log2_freq_start-1 # mod depth shoudl actually be negative .mod_depth_negative = -abs(.mod_depth) # convert dB value to a multiplier .mod_depth_mult = 1-(10^(.mod_depth_negative/20)) # make the carrier if .use_noise do ("Create Sound from formula...", "Carrier", 1, 0, .duration, sampling_frequency, "randomGauss(0,0.1)") elsif .use_tone_complex Create Sound as tone complex: "Carrier", 0, .duration, sampling_frequency, "cosine", .tc_F0, .final_HP, .final_LP, 0 endif # this is the main spectral filter do ("Filter (formula)...", "if x>10 then self*((1-.mod_depth_mult/2)+(sin(((log2(x)-log2_freq_offset)*2*pi*.ripples_per_octave)+(.phase/360*2*pi)))*(0.5*.mod_depth_mult)) else self fi; rectangular band filter") Rename... Temp # here's where we coudl randomize the phase if we wanted... # low pass and high pass do ("Filter (stop Hann band)...", 0, .final_HP, .final_skirt_low) do ("Filter (pass Hann band)...", 0, .final_LP, .final_skirt_high) # make a label to show phase in object name if .phase < 100 .phase$ = "0'.phase:0'" else .phase$ = "'.phase:0'" endif if .phase < 10 .phase$ = "00'.phase:0'" endif # make the name of the sound .mod_depth_10 = round(.mod_depth*10) .mod_depth_label$ = "'.mod_depth_10'" # add leading zero for small mod depth if .mod_depth < 10 .mod_depth_label$ = "0'.mod_depth_label$'" endif # final naming Rename... Ripple_'.ripples_per_octave:2'_'.phase$'_'.mod_depth_label$' finalName$ = selected$("Sound") if .buffer_edges_with_noise = 1 # make lower-freq noise select Sound Noise do ("Filter (pass Hann band)...", 0, .final_HP+(.final_HP/2), .final_skirt_low) Rename... Buffer_low select Sound Noise do ("Filter (stop Hann band)...", 0, .final_LP-(.final_LP/2), .final_skirt_high) Rename... Buffer_high select Sound 'finalName$' Formula... self [col] + Sound_Buffer_low [col] + Sound_Buffer_high [col] select Sound Buffer_low plus Sound Buffer_high Remove endif # cleanup select Sound 'finalName$' call ramp_onset_offset 'finalName$' .ramp_duration Scale intensity... '.final_intensity' select Sound Carrier plus Sound Temp plus Sound Temp_band Remove endproc procedure ramp_onset_offset .name$ .ramptime select Sound '.name$' start1 = Get start time end1 = Get end time Formula... if x('end1' - '.ramptime') ...then self * (1-((x-end1 + '.ramptime')/'.ramptime')) ...else self endif endif endproc procedure make_silence .duration .newname$ # constant sampling_frequency = 44100 Create Sound from formula: "'.newname$'", 1, 0, .duration, 44100, "0" endproc