--- title: "Musical range" id: 50622 type: "computer_media" slug: "musical-range" url: "http://localhost/computer_media/musical-range/" markdown_url: "http://localhost/computer_media/musical-range.md" published_at: "2023-06-23T11:26:01+00:00" modified_at: "2026-04-01T10:56:22+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2019/02/20230809-041332.jpg" excerpt: "Watch block graphics trace a path across the screen while BEEP sweeps through a wide musical range, then descends with a swooping sound effect." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" genre: - name: "Music" slug: "music" taxonomy: "genre" url: "http://localhost/type/music/" media_type: "Program" download_url: "https://archive.org/download/timex-sinclair-software-archive/Musical%20range%20%28198x%29%28TS2068%29%28US%29%28Program%29.zip" mediadate: "198x" media_type_tags: "Music" --- # Musical range Musical range demonstrates the BEEP command across a wide span of pitches, from note –25 to note 30, while simultaneously drawing a diagonal pattern of block graphics on screen to visualize the ascending scale. After the scale completes, a second loop descends from note 60 down to 20 with a different block graphic moving across the display, creating a rudimentary pitch-visualization effect. The program ends with two rapid BEEP calls at the extremes of the earlier range. The DATA statement at line 55 supplies the loop bounds for the initial scale, read via a single READ statement. *** ## Program Analysis ### Program Structure The program divides into three distinct phases: 1. **Ascending scale (lines 10–55):** Reads the pitch range from a `DATA` statement and plays each semitone from –25 to 30 with a half-second `BEEP`, printing a block graphic diagonally to suggest a rising pitch contour. 2. **Pause and clear (line 60):** Waits roughly 3.3 seconds then clears the screen before the next section. 3. **Descending effect (lines 80–130):** Loops from note 60 down to 20 in steps of –1, printing a different block graphic at a position that moves upward as the pitch falls, then fires two staccato `BEEP`s at the extreme low and high notes. ### BEEP Usage All sound is produced via `BEEP` with a constant duration of 0.5 seconds in both loops. The pitch argument (`n`) is used directly as a semitone offset from middle A. In the first loop the range –25 to 30 covers just over four and a half octaves. The final two `BEEP` calls at line 130 use very short durations (0.05 and 0.1 seconds) to produce brief accent tones at the extremes of the first loop’s range. ### Screen Visualization In the ascending loop, `PRINT AT (13-n/3),(n+1/2)` places the block graphic `▌` (the `\::` escape, a left-half block) along a diagonal: as `n` increases the column moves right and the row moves up, mapping pitch to a rising line across the display. Integer truncation in BASIC means the fractional offsets `n/3` and `1/2` (the latter always 0) act as step-down divisors rather than true fractions. In the descending loop, `PRINT AT (30-n/2),12` fixes the column at 12 while the row rises as `n` decreases, so the graphic `▖` (`\.'`, a lower-left quadrant block) climbs the screen as the pitch falls — an inversion of the visual metaphor used in the first section. ### Key BASIC Idioms and Techniques - `READ p1,p2` with a remote `DATA` statement (line 55) cleanly separates the loop parameters from the loop logic. - The expression `(n+1/2)` in the `AT` column argument evaluates as `n+0` due to integer truncation of `1/2`, making it effectively `n` with no practical offset — a minor redundancy. - The variable `x` (lines 80–110) is decremented each iteration but never used in any expression, making it a dead variable with no effect on program behavior. - The two statements on line 60 are separated by a colon, a standard idiom for combining a timed pause and screen clear in a single line. ### Bugs and Anomalies - The `AT` row expression `13-n/3` in the first loop: when `n` reaches 30, the row becomes `13-10 = 3`, well within bounds, but at `n = -25` it yields `13-(-8) = 21`, still valid. However, at `n` values where `n/3` truncates inconsistently, multiple consecutive pitches may share the same row, causing overprinting rather than a smooth diagonal. - The comment in line 15 says “Lowest and highest frequency” but the values are semitone offsets, not frequencies in Hz. - The `x` variable is initialized and decremented (lines 80–110) but never read, serving no computational purpose. ## Source Code ``` 5 REM Musical range 10 READ p1,p2 15 REM Lowest and highesr frequency 20 FOR n=p1 TO p2 30 BEEP .5,n 40 PRINT AT (13-n/3),(n+1/2);"\::" 50 NEXT n 55 DATA -25,30 60 PAUSE 200: CLS 70 REM Sound effect 80 LET x=.1 90 FOR n=60 TO 20 STEP -1 95 PRINT AT (30-n/2),12;"\.'" 100 BEEP .5,n 110 LET x=x-1 120 NEXT n 130 BEEP .05,-25: BEEP .1,30 ```