How to resolve the algorithm Musical scale step by step in the ZX Spectrum Basic programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Musical scale step by step in the ZX Spectrum Basic programming language

Table of Contents

Problem Statement

Output the 8 notes of the C major diatonic scale to the default musical sound device on the system. Specifically, pitch must be tuned to 12-tone equal temperament (12TET) with the modern standard A=440Hz. These are the notes "C, D, E, F, G, A, B, C(1 octave higher)", or "Do, Re, Mi, Fa, Sol, La, Si/Ti, Do(1 octave higher)" on Fixed do Solfège. For the purpose of this task, Middle C (in the case of the above tuning, around 261.63 Hz) should be used as the starting note, and any note duration is allowed. For languages that cannot utilize a sound device, it is permissible to output to a musical score sheet (or midi file), or the task can be omitted.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Musical scale step by step in the ZX Spectrum Basic programming language

Source code in the zx programming language

10 REM Musical scale
20 LET n=0: REM Start at middle C
30 LET d=0.2: REM Make each note 0.2 seconds in duration
40 FOR l=1 TO 8
50 BEEP d,n
60 READ i: REM Number of semitones to increment
70 LET n=n+i           
80 NEXT l
90 STOP
9000 DATA 2,2,1,2,2,2,1,2:REM WWHWWWH

  

You may also check:How to resolve the algorithm One-dimensional cellular automata step by step in the Haskell programming language
You may also check:How to resolve the algorithm Image noise step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Check output device is a terminal step by step in the Haskell programming language
You may also check:How to resolve the algorithm Date manipulation step by step in the UNIX Shell programming language
You may also check:How to resolve the algorithm Department numbers step by step in the Quackery programming language