# this is a one-beat metronome
# Hugo Quené, hquene@indiana.edu, Nov 2001
# based on metronomeL.praat
# adapted 10/Jan/2002 for Jitter
# the jitter factor is defined as the standard deviation of the nominal metronom cycle,
# relative to that cycle.
# For a run with J=.05, M=.5, periods are sampled from a normal distribution
# with mean=M=.5, and s=(J*M)=(.05*.5)=.025.
# Hence J=s/M=.25/.5=.5 QED.
# adapted 11/Jan/2002 for alternation
# ie speak out for N cycles, then keep quiet for N cycles, then recommence
#
# this version is stripped from metronome.jitter.alt.praat
# without the alternation stuff
# HQ 15 Jan 2002
form Jittery Metronome (1-beat)
positive frequency_(bpm) 60
positive duration_(s) 60
comment Jitter is defined here as the normalised standard deviation of the metronome period.
comment With F=120 bpm, a nominal period is 60/120 = 0.5 seconds.
comment With J=0.1, actual periods are randomly sampled from a normal distribution
comment with mean=0.5 and s=(J*mean)=(0.1*0.5)=0.05 seconds.
positive jitter_(fraction) 0.1
comment Amplitude factor for metronome beeps:
positive amplitude
endform
# instead of determining cycletime and pausetime once,
# the jittery metronome has to do that for every cycle, so bring this into loop
normaltime = 60/'frequency'
tonetime = 0.040
# pausetime =3D 'cycletime'-'tonetime'
clearinfo
cycles = floor( 'duration'/'normaltime' )
# altcycles = 'number_of_cycles'
# speaking = 1
# printline 'cycles'
while cycles>0
# for the jittery metronome: determine cycledur, pausedur, and concatenate
cycletime = randomGauss(normaltime,normaltime*jitter)
# printline 'cycles','cycletime','speaking'
printline 'cycles','cycletime'
# if we are speaking then make a beep, otherwise make a silent interval
# if 'speaking'
Create Sound... Ltone 0 'tonetime' 44100 'amplitude'*sin(2*pi*400*x)
# else
# Create Sound... Ltone 0 'tonetime' 44100 0
# endif
pausetime = cycletime-tonetime
Create Sound... stil 0 'pausetime' 44100 0
select Sound Ltone
plus Sound stil
Concatenate
# this yields a new Sound named 'chain'
Play
cycles = cycles-1
# altcycles = altcycles-1
# have we done our N cycles between alternations?
# if altcycles==0
# speaking=!speaking
# altcycles = 'number_of_cycles'
# endif
# to clear Praat memory, stuff must be cleaned immediately!
select Sound Ltone
plus Sound stil
plus Sound chain
Remove
endwhile
# end of script