Post by spannernick on Oct 10, 2018 20:17:50 GMT
I thought this was interesting..
:10,0
SIDPLAYER MUSIC FILE CONTENTS:10,0
BY DICK THORNTON
:10,60
SIDPLAYER MUSIC FILES ARE PRG TYPE FILES WHICH CONTAIN THE
MUSICAL NOTES AND COMMAND DIRECTIVES FOR PLAYING A SONG, AS
WELL AS THE SEVERAL TEXT LINES INTENDED FOR THE SONG NAME
AND CREDIT LINES FOR THE COMPOSER AND SID ARRANGER.
ON DISK, THE FILE CONSISTS OF ONE OR MORE SECTORS WRITTEN IN
STANDARD PRG FORMAT. CHARACTERISTICS OF THIS FILE TYPE CAN
BE FOUND IN YOUR DISK MANUAL, OR OTHER BOOKS ON DISK FILE
MANAGEMENT. FROM HERE ON, WE WILL CONSIDER THE FILE DATA AS
IT RESIDES IN MEMORY AFTER BEING LOAD'ED. THE GENERAL FORMAT
OF THE .MUS FILE IN MEMORY IS:
:10,0
(1) TWO-BYTE LENGTH OF VOICE 1 IN LOW-BYTE, HIGH-BYTE FORM.(2) TWO-BYTE LENGTH OF VOICE 2 IN LOW-BYTE, HIGH-BYTE FORM.
(3) TWO-BYTE LENGTH OF VOICE 3 IN LOW-BYTE, HIGH-BYTE FORM.
(4) THE DATA FOR VOICE 1 ALWAYS ENDING WITH A HLT COMMAND.
(5) THE DATA FOR VOICE 2 ALWAYS ENDING WITH A HLT COMMAND.
(6) THE DATA FOR VOICE 3 ALWAYS ENDING WITH A HLT COMMAND.
(7) THE TEXT LINES FOR SONG NAME, ETC. THERE ARE FIVE
LINES, EACH CONTAINING 0-32 BYTES AND ENDING WITH A
CARRIAGE RETURN. THE TEXT DATA INFORMATION IS IN
UPPER-CASE COMMODORE PET ASCII. A HEX ZERO BYTE FOLLOWS
THE LAST BYTE OF THE LAST LINE OF TEXT.
:10,60
THE EFFECT OF THIS IS THAT EACH .MUS FILE IS ACTUALLY FOUR
FILES PACKED END-TO-END IN A SINGLE PRG FILE WITH THREE
LITTLE TWO-BYTE LENGTHS IN THE FRONT TO HELP YOU FIND
THINGS. VOICE 1 BEGINS AT THE SIXTH BYTE OF THE DATA FILE AS
LOAD'ED INTO MEMORY. VOICE 2 STARTS AT A POINT 6 + LENGTH OF
VOICE 1 FROM THE BEGINNING OF THE FILE IN MEMORY. VOICE 3 IS
AT 6 + LENGTH OF VOICE 1 + LENGTH OF VOICE 2 FROM THE FILE
START, AND THE TEXT LINES BEGIN AT 6 + LENGTH OF VOICE 1 +
LENGTH OF VOICE 2 + LENGTH OF VOICE 3. EACH VOICE ENDS WITH
A HLT COMMAND (HEX 014F), AND IF THERE IS NO DATA FOR A
VOICE THAT IS ALL IT WILL CONTAIN. THE TEXT AREA ENDS WITH A
HEX ZERO AFTER THE CARRIAGE RETURN FOR THE FINAL LINE.
EACH VOICE CONTAINS DATA IN TWO-BYTE PAIRS THAT CONTAIN THE
MUSICAL NOTES AND COMMANDS NEEDED TO PLAY THE SONG. THE
FIRST BYTE OF EACH PAIR WILL HAVE BITS 1 AND 0 BOTH SET TO
ZERO IF THE BYTE-PAIR DESCRIBES A MUSICAL NOTE, OTHERWISE
THE BYTE-PAIR DESCRIBES A SID CHIP COMMAND OR SIDPLAYER
COMMAND.
IN THE FOLLOWING, COMMANDS ARE IDENTIFIED BY THE THREE
CHARACTER ABBREVIATION USED BY THE SID EDITOR PROGRAM
DESCRIBED IN THE BOOKS "ALL ABOUT THE COMMODORE 64" VOLUME
2, AND "COMPUTE!'S MUSIC SYSTEM FOR THE COMMODORE 128 AND
64". BOTH BOOKS ARE PUBLISHED BY COMPUTE! BOOKS.
:10,0
- PAGE 1 -
MUSICAL NOTE DATA PAIRS
:10,60
MUSICAL NOTE DATA PAIRS WILL CONTAIN 00 IN THE LOWER-ORDERTWO BITS OF THE FIRST BYTE OF THE PAIR. EACH MUSICAL NOTE
BYTE-PAIR CONTAINS DURATION IN ITS FIRST BYTE, AND FREQUENCY
(PITCH) IN THE SECOND. THIS DATA IS CODED AS FOLLOWS, WHERE
THE PARENTHETIC NUMBER FOLLOWING A BIT NUMBER IS THE HEX
VALUE OF THAT BIT:
:10,0
BYTE 1 - TIE AND DURATION
BIT 7 (80) ALWAYS 0
BIT 6 (40) 1=TIE TO NEXT NOTE. 0=NOT TIED
BIT 5 (20) 1=DOTTED NOTE DURATION. 0=NOT DOTTED
BIT 4 (10) BITS 4 3 2 NOTE DURATION
BIT 3 (08) . 1 1 1 32ND NOTE
BIT 2 (04) . 1 1 0 16TH NOTE
. 1 0 1 8TH NOTE
. 1 0 0 QUARTER NOTE
. 0 1 1 HALF NOTE
. 0 1 0 WHOLE NOTE
. 0 0 1 UTILITY DURATION
. 0 0 0 ABSOLUTE PITCH
BIT 1 (02) ALWAYS 0 FOR NOTE PAIRS
BIT 0 (01) ALWAYS 0 FOR NOTE PAIRS
BYTE 2 - FREQUENCY (PITCH) AND RESTS
BIT 7 (80) BITS 7 6 PITCH MODIFICATION
BIT 6 (40) . 1 1 FLATTED NOTE
. 1 0 NATURAL NOTE
. 0 1 SHARPED NOTE
BIT 5 (20) BITS 5 4 3 OCTAVE NUMBER
BIT 4 (10) . 1 1 1 OCTAVE 0
BIT 3 (08) . 1 1 0 OCTAVE 1
. 1 0 1 OCTAVE 2
. 1 0 0 OCTAVE 3
. 0 1 1 OCTAVE 4
. 0 1 0 OCTAVE 5
. 0 0 1 OCTAVE 6
. 0 0 0 OCTAVE 7
BIT 2 (04) BITS 2 1 0 NOTE LETTER IDENTIFIER
BIT 1 (02) . 1 1 1 B NOTE
BIT 0 (01) . 1 1 0 A NOTE
. 1 0 1 G NOTE
. 1 0 0 F NOTE
. 0 1 1 E NOTE
. 0 1 0 D NOTE
. 0 0 1 C NOTE
. 0 0 0 REST
- PAGE 2 -
COMMAND DATA PAIRS
:10,60
COMMANDS CONTAIN INFORMATION OTHER THAN MUSICAL NOTE PITCHAND DURATION. FOR COMMANDS, THE LOW-ORDER TWO BITS OF THE
FIRST BYTE ARE NOT 00. A WHOLE SET OF COMMANDS ARE
IDENTIFIED WITH A FIRST BYTE VALUE OF HEX 01. FOR THESE
COMMANDS, THE LOW-ORDER FOUR BITS OF THE SECOND BYTE CAN BE
USED AS A GROSS IDENTIFIER, WHILE THE HIGH ORDER FOUR BITS
OFTEN CONTAIN A NUMERIC VALUE. THESE COMMANDS ARE DESCRIBED
BY THEIR SECOND BYTES BELOW:
:10,0
COMMANDS WITH FIRST BYTE = HEX 01
* BYTE2 * HEX COMMAND VALUE
7654 3210 NAME
NNNN 0000 N0 DCY BITS 7654 CONTAIN A VALUE, 0-F
NNNN 0010 N2 CAL BITS 7654 CONTAIN A VALUE, 0-F
0000 0011 03 BMP UP
0001 0011 13 FLT NO
0010 0011 23 RNG NO
0011 0011 33 SNC NO
0100 0011 43 F-X NO
0101 0011 53 3-0 NO
0NNN N100 ATK BITS 6543 CONTAIN A VALUE, 0-F
1NNN N100 SUS BITS 6543 CONTAIN A VALUE, 0-F
NNNN 0110 N6 DEF BITS 7654 CONTAIN A VALUE, 0-F
NNN0 0111 N7 WAV BITS 7 6 5 WAVEFORM
0 0 0 NOISE
0 0 1 TRIANGLE
0 1 0 SAWTOOTH
0 1 1 TRIANGLE + SAWTOOTH
1 0 0 PULSE
1 0 1 PULSE + TRIANGLE
1 1 0 PULSE + SAWTOOTH
1 1 1 PULS+TRIANG+SAWTOO
NNN1 0111 N7 F-M BITS 7 6 5 FILTER MODE
0 0 0 OFF
0 0 1 LOW PASS
0 1 0 BAND PASS
0 1 1 LOW + BAND
1 0 0 HIGH PASS
1 0 1 HIGH + LOW
1 1 0 HIGH + BAND
1 1 1 HIGH + BAND + LOW
NNNN 1000 N8 RLS BITS 7654 CONTAIN A VALUE, 0-F
NNNN 1010 NA RES BITS 7654 CONTAIN A VALUE, 0-F
0000 1011 0B BMP DOWN
0001 1011 1B FLT YES
0010 1011 2B RNG YES
0011 1011 3B SNC YES
0100 1011 4B F-X YES
0101 1011 5B 3-0 YES
NNNN 1110 NE VOL BITS 7654 CONTAIN A VALUE, 0-F
0000 1111 0F TAL N/A
0010 1111 2F END N/A
0100 1111 4F HLT N/A
- PAGE 3 -
COMMANDS WHOSE FIRST BYTE IS NOT HEX 01
:10,60
THIS GROUP OF COMMAND PAIRS GENERALLY HAS A FIRST BYTE THATDEFINES THE COMMAND, AND THE SECOND BYTE GIVES A NUMERIC
VALUE FROM HEX 00 TO FF (DECIMAL RANGE 0 TO 255). THERE ARE
A FEW VARIATIONS, HOWEVER, WHERE THE VALUE RANGE EXCEEDS 255
(DTN AND POR), AND WHERE NEGATIVE VALUES MUST BE AVAILABLE (AUT,
P-S, TPS, AND DTN).
:10,0
BYTE1 * BYTE2 * CMD
HEX 7654 3210 NAME VALUE
N2 NNNN NNNN P-W THE 12-BIT NUMBER COMPOSED OF
BYTE 1, BITS 7-4 AND ALL 8
BITS OF BYTE 2 GIVE A RANGE OF
0-4,095.
06 NNNN NNNN TEM IF THE SECOND BYTE IS ZERO, IT
IS REPLACED BY 256 (HEX 100).
THE SECOND BYTE VALUE IS THEN
DIVIDED INTO 14,400. THE WHOLE
NUMBER QUOTIENT IS THE NUMBER
OF QUARTER NOTES PER MINUTE.
16 NNNN NNNN UTL SECOND BYTE IS THE VALUE.
26 NNNN NNNN PNT SECOND BYTE IS THE VALUE.
36 NNNN NNNN HED SECOND BYTE IS THE VALUE.
46 NNNN NNNN FLG SECOND BYTE IS THE VALUE.
56 SNNN NNNN P-S SECOND BYTE CONTAINS THE VALUE
AS A SIGNED NUMBER WITH RANGE
-127 (HEX 81) TO +127 (HEX 7F)
66 SNNN NNNN F-S SECOND BYTE CONTAINS THE VALUE
AS A SIGNED NUMBER WITH RANGE
-127 (HEX 81) TO +127 (HEX 7F)
76 0NNN NNNN VDP BYTE 2 BITS 6-0 CONTAIN THE
VALUE, 0-127.
86 NNNN NNNN VRT SECOND BYTE IS THE VALUE.
96 SNNN NNNN AUT SECOND BYTE CONTAINS THE VALUE
AS A SIGNED NUMBER WITH RANGE
-127 (HEX 81) TO +127 (HEX 7F)
- PAGE 4 -
A6 HHHH OOOS TPS THE SECOND BYTE CONTAINS THE
NUMBER OF HALF-STEPS TO TRANS-
POSE, FROM -95 TO +95. BIT 0
IS THE SIGN, 0=+. 1=-. BITS
3-1 GIVE THE NUMBER OF WHOLE
OCTAVES FOR NEGATIVE VALUES.
FOR POSITIVE NUMBERS, THE
NUMBER OF OCTAVES IS 7 MINUS
THE NUMBER IN BITS 3-1. BITS
7-4 GIVE THE ADDITIONAL HALF-
STEPS LESS THAN AN OCTAVE (0-
11) FOR POSITIVE NUMBERS. FOR
NEGATIVE NUMBERS, THE EXCESS
HALF-STEPS ARE 11 MINUS THE
NUMBER IN BITS 7-4.
B6 NNNN NNNN AUX SECOND BYTE IS THE VALUE.
0E NNNN NNNN F-C SECOND BYTE IS THE VALUE.
NE NNNN NNNN MEA THE 10-BIT NUMBER COMPOSED OF
BITS 7-6 OF THE 1ST BYTE AND
ALL 8 BITS OF THE SECOND BYTE
GIVE A VALUE OF 0-1,024. BIT 5
AND 4 ARE ALWAYS 01 FOR THIS
COMMAND, SO THE FIRST BYTE MAY
BE 1E, 5E, 9E, OR DE.
NA NNNN NNNN DTN THE 11-BIT NUMBER COMPOSED OF
BYTE 1, BITS 7-5 AND ALL 8 BITS
OF BYTE 2 PRODUCES A VALUE OF
0-2,048. IF BYTE 1, BIT 4 IS 1,
THE NUMBER IS NEGATIVE, AND IS
REDUCED BY 2,048 FOR AN
EFFECTIVE RANGE OF -2,048 TO
+2,048.
NN NNNN NNNN POR THE 14-BIT NUMBER COMPOSED OF
BYTE 1, BITS 7-3 AND ALL 8
BITS OF THE SECOND BYTE. VALUE
RANGE IS 0 TO 16,383. BITS 1 AND
0 OF BYTE 1 ARE ALWAYS 11 FOR THIS
COMMAND, ALL OTHER BITS MAY BE ANY
VALUE.
:0,60