# select all
# nocheck Remove

chunk = 0.00125

sound_id = Create Sound from formula: "sine", 1, 0, 0.05, 44100, "1/2 * sin(2*pi*200*x)"
duration = Get total duration
part_1 = Extract part: 0, duration / 2, "rectangular", 1.0, "no"
selectObject: sound_id
part_2 = Extract part: duration / 2, duration, "rectangular", 1.0, "no"
part_3 = Extract part: chunk, duration / 2, "rectangular", 1.0, "no"
selectObject: sound_id
part_4 = Extract part: chunk * 2, duration / 2, "rectangular", 1.0, "no"

Erase all
selectObject: part_1
Select inner viewport: 0.7, 5.3, 0.45, 2.1
  Solid line
  Blue
  Line width: 2
    Draw: 0, 0, 0, 0, "no", "Curve"
  Black
  Line width: 1
  Dotted line
    Draw line: 0, 0, duration / 2, 0
  Solid line
Marks left: 2, "yes", "yes", "no"
Draw inner box
Select outer viewport: 0.3, 5.4, 0.3, 2.2
Save as 300-dpi PNG file: "00_sine_1"

# pause

Erase all
selectObject: part_3
Select inner viewport: 0.7, 5.3, 0.45, 2.1
  Blue
  Line width: 2
    Draw: 0, 0, 0, 0, "no", "Curve"
  Black
  Line width: 1
  Dotted line
    Draw line: 0, 0, (duration / 2) - chunk, 0
  Solid line
Marks right: 2, "yes", "yes", "no"
Draw inner box
Select outer viewport: 0.6, 5.7, 0.3, 2.2
Save as 300-dpi PNG file: "00_sine_2"

# pause

selectObject: part_1, part_3
bad_crossing_id = Concatenate
duration = Get total duration
Erase all
Select inner viewport: 0.7, 5.3, 0.45, 1.2
  Blue
    Draw: 0, 0, 0, 0, "no", "Curve"
  Black
  Dotted line
    Draw line: 0, 0, duration, 0
  Solid line
Marks right: 2, "yes", "yes", "no"
Draw inner box
Select inner viewport: 0.7, 5.3, 1.2, 3
spec_id = To Spectrogram: 0.005, 5000, 0.002, 20, "Gaussian"
Paint: 0, 0, 0, 0, 100, "yes", 50, 6, 0, "no"
Draw inner box
Select outer viewport: 0.6, 5.7, 0.3, 3.1
Save as 300-dpi PNG file: "00_sine_3_bad_cross"

# pause

selectObject: part_1, part_3
good_crossing_id = Concatenate with overlap: 0.01
duration = Get total duration
Erase all
Select inner viewport: 0.7, 5.3, 0.45, 1.2
  Blue
    Draw: 0, 0, 0, 0, "no", "Curve"
  Black
  Dotted line
    Draw line: 0, 0, duration, 0
  Solid line
Marks right: 2, "yes", "yes", "no"
Draw inner box
Select inner viewport: 0.7, 5.3, 1.2, 3
spec_id = To Spectrogram: 0.005, 5000, 0.002, 20, "Gaussian"
Paint: 0, 0, 0, 0, 100, "yes", 50, 6, 0, "no"
Draw inner box
Select outer viewport: 0.6, 5.7, 0.3, 3.1
Save as 300-dpi PNG file: "00_sine_5_good_cross"

selectObject: part_1, part_4
bad_crossing_id = Concatenate
duration = Get total duration
Erase all
Select inner viewport: 0.7, 5.3, 0.45, 1.2
  Blue
    Draw: 0, 0, 0, 0, "no", "Curve"
  Black
  Dotted line
    Draw line: 0, 0, duration, 0
  Solid line
Marks right: 2, "yes", "yes", "no"
Draw inner box
Select inner viewport: 0.7, 5.3, 1.2, 3
spec_id = To Spectrogram: 0.005, 5000, 0.002, 20, "Gaussian"
Paint: 0, 0, 0, 0, 100, "yes", 50, 6, 0, "no"
Draw inner box
Select outer viewport: 0.6, 5.7, 0.3, 3.1
Save as 300-dpi PNG file: "00_sine_4_bad_cross_at_0"
