Refactored drawing routines and changed pitch extracting settings
[sgc2.git] / ToneProt / DrawToneContour.praat
blobdce1458ee81c78f340cc2b3e665a2af3f41d0b19
1 #! praat
4 # Draw the correct tone tracks
6 # Needs
7 # include ToneScript.praat
9 procedure drawToneContour drawToneContour.pinyin$ drawToneContour.register
10         # Clean up input
11         if drawToneContour.pinyin$ <> ""
12         drawToneContour.pinyin$ = replace_regex$(drawToneContour.pinyin$, "^\s*(.+)\s*$", "\1", 1)
13         drawToneContour.pinyin$ = replace_regex$(drawToneContour.pinyin$, "5", "0", 0)
14         endif
16         # Generate reference example
17         # Start with a range of 1 octave and a speed factor of 1
18         drawToneContour.toneRange = 1.0
19         drawToneContour.speedFactor = 1.0
20         call toneScript 'drawToneContour.pinyin$' 'drawToneContour.register' 1 1 CorrectPitch
21         drawToneContour.freqTop = 1.5 * drawToneContour.register
23         # Draw Pitch track
24         select Pitch 'drawToneContour.pinyin$'
25         demo Select outer viewport... 20 80 40 100
26         demo Axes... 0 100 0 100
27         demo Line width... 1
28         demo Green
29         demo Draw... 0 0 0 'drawToneContour.freqTop' 0
30         demo Line width... 3
31         demo Green
32         demo Draw... 0 0 0 'drawToneContour.freqTop' 0
33         demo Select outer viewport... 0 100 0 100
34         demo Axes... 0 100 0 100
36         # Clean up
37         select Pitch 'drawToneContour.pinyin$'
38         Remove
39 endproc
42 procedure drawSourceToneContour drawToneContour.sourcePitch
43         if drawToneContour.sourcePitch > 0
44                 call reset_viewport
45                 demo Select inner viewport... 20 80 40 100
46                 demo Axes... 0 100 0 100
47         
48             select drawToneContour.sourcePitch
49             demo Red
50             demo Line width... 3
51             demo Draw... 0 0 0 'freqTop' 0
52         
53             demo Line width... 1
54                 call reset_viewport
55         endif
56 endproc