User Tools

Site Tools


sd:a_guide_to_sound_and_music_on_the_sd-8516

A Guide to Sound and Music on the SD-8516

Introduction

Welcome to your exciting journey into sound! The SD-8516 offers a rich array of sound and music playing capabilities, for you to discover.

Inside you will find detailed information and examples for:

  • Stellar Basic's PLAY statement
  • Details on programming the SDC-450 Synthesizer sound chip
  • How to use the SPC-1000 and Star Tracker for sample-based sounds

Stellar BASIC's PLAY statement

Both Assembly and BASIC programmers can use the MML system, either via BASIC's PLAY statement, or in assembly via INT 11h music services.

Notes

Basic's PLAY statement is extremely similar to the standard BASIC PLAY statement found in typical BASIC implementations.

  10 PLAY "A"

This will play the note “A” in the default waveform. You can play any note from A to G. To play a sharp, try A# or A+. To play a flat, try A-. This notation is fun and easy to remember!

The next thing you might want to do is change the length of the notes. The default length is quarter note. To play in a different length you simply add the length of the note to the note:

  10 PLAY "C E8 E8 E8 F"

After playing E as an 8th note, F is played again as a quarter note. The time is essentially a fraction of a whole note; you can try playing 16th notes, 32nd notes, 64th notes, or as you like.

Rest is R:

  10 PLAY "C E8 R8 E8 F"

Tempo

You can change tempo with the T command. The default tempo is 120:

  10 PLAY "T160 C8 R8 E8 R16 E16 F."

This spritely little toot shows the Tempo command (T). Did you notice anything special or new here? Yes, there's a dotted note. Dotted notes are musical dot notation, where the note is held for an extra half of it's length.

Default Note Length

If you want to change the note length to something other than quarter note, use the L command.

  PLAY "L8"

This will change the default note length to an 8th note.

  PLAY "MS A B C"
  • The MS command makes the following notes play staccato.
  • The ML command makes the following notes play legato.
  • The MN command returns note playing to normal.

Octave

You can change octaves easily. > and < play up and down one octave, while On sets the octave:

  10 PLAY "E16 E16 E16 R16 < G16 G16 G16 R16 > C16 D16 C16 D16 C"

This is starting to sound like music!

Waveform Synth

You can control the waveform being used via the W command.

  PLAY "W0 C D E"

This plays nothing because 0 means gate-off (mute). However, W with one of the following will give you a different sound:

  W1 -- Square waveform (default)
  W2 -- Triangle waveform
  W3 -- Sawtooth waveform
  W4 -- Sine waveform
  W5 -- PWM waveform (variable width)

You can set the pulse width with the extended XP command.

  PLAY "W5 XP100 C XP300 D XP900 E XP2000 F XP2700 G XP3500 A"

Polyphonic sound

The MML system used by BASIC enables polyphonic (multivoice) sound. To play multivoice sound, use the XV command to change voices, and the XW command to sync all voices together.

10 REM SETUP: Tempo 132, L4 (quarter note default), MN (normal length notes)
20 PLAY "T132 L4 MN"
30 REM Main melody (violins)
40 PLAY "XV1 O5 V13 XW G4 R8 D8 G4 R8 D8 | G8 D8 G8 B8 >D4 R4 | C4 R8 <A8> C4 R8 <A8> | C8 <A8 F#8 A8 D4 R4"
50 REM Bass / cello foundation
60 PLAY "XV2 O3 V9 XW G4 R8 D8 G4 R8 D8 | G8 D8 G8 B8 >D4 R4 | C4 R8 <A8> C4 R8 <A8> | C8 <A8 F#8 A8 D4 R4"

The XW shown above is insurance that the channels will play in sync. Normally there shouldn't be an issue if you play two or three lines right after each other, but it may become more necessary for longer, multivoice songs.

When you RUN this program, it plays the music and immediately returns to the READY prompt. This is because it is playing music in the background.

Other Commands

  • XC - clear current voice queue
  • XT - Tuning. Ex. XT415 sets A=415hz for baroque-authentic tuning.

PLAY for Assembly

You can use PLAY in assembly too. Just use the music services library, INT 11h. Here's the same demo song by Mozart as abobe, but for the Assembler:

mozart_demo:
    LDELM @play_setup
    LDAH $52
    INT $11
    
    LDELM @play_1
    LDAH $52
    INT $11
    
    LDELM @play_2
    LDAH $52
    INT $11
    
    RET

play_setup:
    .bytes "T132 L4 MN", 0

play1:
    ; Main melody (violins)
    .bytes "XV1 O5 V13 XW G4 R8 D8 G4 R8 D8 "
    .bytes "G8 D8 G8 B8 >D4 R4 "
    .bytes "C4 R8 <A8> C4 R8 <A8> "
    .bytes "C8 <A8 F#8 A8 D4 R4", 0
    
play2:
    ; Bass / cello foundation
    .bytes "XV2 O3 V9 XW G4 R8 D8 G4 R8 D8 "
    .bytes "G8 D8 G8 B8 >D4 R4 "
    .bytes "C4 R8 <A8> C4 R8 <A8> "
    .bytes "C8 <A8 F#8 A8 D4 R4", 0

Here are all the MML commands you can use in Assembly:

From INT 11h:

  • AH=$50: MML_STOP, Stop MML playback
  • AH=$51: MML_START, Resume MML playback
  • AH=$52: MML_PLAY - Parse and queue MML string
  • AH=$53: MML_CLEAR - Clear all MML state and silence voices
sd/a_guide_to_sound_and_music_on_the_sd-8516.txt · Last modified: by appledog

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki