Task

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.

DEFINE PTR="CARD"
 
PROC Wait(BYTE frames)
  BYTE RTCLOK=$14
  frames==+RTCLOK
  WHILE frames#RTCLOK DO OD
RETURN
 
PROC Main()
  BYTE AUDCTL=$D208,AUDF1=$D200,AUDC1=$D201,AUDF2=$D202,AUDC2=$D203
  PTR ARRAY notes(8)
  BYTE ARRAY pitch8=[60 53 47 45 40 35 31 30]
  CARD ARRAY pitch16=[1703 1517 1350 1274 1134 1010 899 848]
  BYTE i
  CARD p
 
  notes(0)="Do" notes(1)="Re" notes(2)="Mi" notes(3)="Fa"
  notes(4)="Sol" notes(5)="La" notes(6)="Si" notes(7)="Do"
 
  PrintE("8-bit precision pitch values:")
  FOR i=0 TO 7
  DO
    PrintF("%S-%B ",notes(i),pitch8(i))
    Sound(0,pitch8(i),10,10)
    Wait(20)
  OD
  SndRst()
  Wait(20)
  PutE() PutE()
 
  AUDCTL=$50 ;join channel 1 and 2 to get 16-bit
  AUDC1=$A0  ;turn off channel 1
  AUDC2=$AA  ;turn on channel 2
  PrintE("16-bit precision pitch values:")
  FOR i=0 TO 7
  DO
    PrintF("%S-%U ",notes(i),pitch16(i))
    p=pitch16(i)
    AUDF2=p RSH 8
    AUDF1=p&$FF
    Wait(20)
  OD
  SndRst()
  AUDCTL=$00 ;restore default configuration
  Wait(20)
RETURN