home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
No Fragments Archive 10: Diskmags
/
nf_archive_10.iso
/
MAGS
/
LEDGERS
/
LEDG_07B.MSA
/
SOURCE
/
MR_MUSIC.V2
/
MR_FORMT.TXT
next >
Wrap
Text File
|
1985-11-20
|
18KB
|
410 lines
Electronic Images presents:
//** MR MUSIC FILE FORMAT **\\
First, a few words from The Phantom:
Hello my little diamonds! Here, for your benefit/pleasure, is the Mr Music
file format structure so you can make your own .SNG files in whichever manner
you want, or to simply convert soundtracker (aggh!) format to Mr Music.
Hope you find this information useful - contact me if you have any problems
(address below) or leave me some mail on CONTACT BBS (London England) on:
+44 (081) 6460746 9PM to 9AM UK time. You can also call it for other things
- it's the best board for your programming/demo/naughty needs!
SECTION 1 - Features.
Apart from being blindingly fast, Mr Music has several features which make it
a little bit more 'special'...
Ability to manipulate over 32000 samples.
Samples can be up to 64K in length.
Extremely small .SNG file size.
Plays from current sample pointer or start of sample (selectable).
Looped samples (or vice versa) can be automatically made non-looped.
It is not restricted by fixed length patterns.
Has up to 255 pattern loops.
Duration of a note/slide/rest up to 32767 units (about 10 minutes!).
And a few more, but they're to do with the player itself.
SECTION 2 - .SNG FILE FORMAT.
Mr Music files are so small because it works bit-wise. Some may moan for the
'slowness' of this method (which it isn't!!!); The Phantom programmed Mr
Music mainly to emulate an expensive keyboard, not a 0.000% CPU time,
old-fashioned music driver. The main advantage of this bit wise format
(apart from compactness) is that ALL operations are perfromed AT THE SAME
TIME. Poor music drivers (like soundtracker and all the derivatives) perform
their functions one-at-a-time. For example; in soundtracker or whatever, if
you want to play a note and slide it then the driver waits one frame (being
1/50th second or whatever it is calibrated at) to play the note, then the
next to slide it. This is hardly noticeable (actually you can't notice it AT
ALL!) but it's not right. Mr Music does it the proper way - performing all
operations concurrently!!!
SONG FORMAT
Simple - you have four 'channels', each channel's data is terminated by a
negative value of -9999. Note that this NEEDS to be -9999 and NO OTHER.
The four channels' data is one after the other. That is, channel 1's data is
first, then a -9999, then channel 2's data, then -9999 and so on, until the
end of channel 4 (again, signalled by a WORD value of -9999). While playing,
when -9999 is reached, the player will automatically loop to the start of the
channel's data and start again.
The actual musical data is governed by a command word, and acted on bitwise
and step-by-step. That is, it starts processing bit 0, then 1 then 2...
Taking each bit's relevant data in step.
Here's a quick summary. The number of '1 W' means the number of WORDS
(2-byte values) that it needs as data.
COMMAND WORD:
Word (bits) - 0100000000001111
|__________||||___ Sustain. Does auto sustain (0 = off).
||||
|______ Rest. 1 W: Duration.
|||
|_____ Slide. 1 W: To note, 1 W: Speed, 1 W: Dur.
||
|____ New note. 1 W: Note, 1 W: Duration.
|
|___ New sample. 1 W: Sample number.
(Dur. means duration.)
(Pattern loops will be explained later)
BIT 15 - Sustain.
This needs no data. This bit in the command word just says that this sample
(if any) has a loop. You can have sustain on non-loop samples; it will
simply loop from the start of the sample.
BIT 0 - New sample.
This bit sets a new sample. It does not play a new sample unless a note or
slide command is issued.
It needs one WORD signifying the sample number (starting from 0).
BIT 1 - New note.
This bit sets a new note - actually playing the sample at your required note.
It needs two WORDS. The first word is the note (0-63 with 31 being the
middle (440Hz) note). The second word the duration in VBL's (in units of
1/50th of a second at 50Hz or 1/60th of a second at 60hz). So a duration
value of 25 will play the note for 1/2 a second at 50Hz. Note that this is
also the time until the next command word is read.
BIT 2 - Slide.
This performs a note slide. For speed, it is not as 'smooth' as other
trackers, but used right, it is very good.
It needs three WORDS. The first word is the destination note it slides to
(from 0-63), the second word is the slide speed in 1/50ths of a second (or
1/60th at 60Hz). The third word is the duration of the slide. If the slide
speed is 2, then slides are performed at 2/50ths of a second (or at 60Hz,
2/60ths) and so on. Please do not let the slide speed exceed the duration
time, otherwise it might go all strange! Say the duration time is 30. If it
has to slide from note 0 to note 63 every 2 units, then it will not reach the
destination note in time (2*63 = 126, which exceeds 30 by a lot!). A slide
from note 10 to 20 at 3 units WILL just do it; 10-20= 10 notes to slide, * 3
units each = 30 duration units (just in, so it will work). Note that slides
that fall well within the duration time will work - they sustain the
destination note for the remaining time until the next note or slide command.
One thing: the smaller the slide speed, the faster it will slide (1 being the
fastest and 32767 the slowest).
Note that this is also the time until the next command word is read.
BIT 3 - Rest.
This simply 'rests' (stops playing the sample) for the required time.
It needs one WORD. The word value is in 1/50ths of a second at 50Hz (or
1/60ths of a second at 60Hz). So a duration value of 50 would wait for 1
second (at 50Hz). Note that this is also the time until the next commnd word
is read.
Now's a little demonstration of a typical command sequence:
Example - Say we want to play a new sample with middle note... Then it would
look like this: (DC.W in assembler is DEFINE CONSTANT of word length)
dc.w %0100000000000011
dc.w 0 Sample number.
dc.w 31 Note.
dc.w 6 Duration.
Observe that the sustain (loop sample) bit is set. The above sequence will
start playing a sample at middle note for 6 units.
And now, let's say that we only want to slide from the current note (which,
say, is 31) to a higher note (slide taking place immediately):
dc.w %0000000000000100
dc.w 41 Destination note.
dc.w 2 Speed of slide.
dc.w 80 Duration.
Observe that the sustain (loop sample) bit is off (just to show that you can
toggle a sample's loop status on-the-fly!). The above sequence (on hearing
it) will slide from middle note (assuming it WAS that) to a higher note and
hold it there until the duration ends (since the slide will get there before
the note ends).
How about a new (looped) sample (number 2) at note 40 sliding down to 30 with
duration 10? Simple.
dc.w %0100000000000111
dc.w 1 Sample number (remember, we start from 0).
dc.w 40 Note.
dc.w 99 Duration - this one is ignorend since the slide's dur. is taken.
dc.w 30 Slide to this note.
dc.w 1 Slide every 1 unit.
dc.w 10 Duration of 10 units.
Pattern loops:
Each voice has INDEPENDENTLY handled loops. That is, they have no fixed
sequence like soundtrackers - this means that the music has a much greater
scope for musical change & rhythm, but the downside of this method is that
you have to look out that all four channels loop at the same time, otherwise
the music will restart out of sync. Mind you, you could always use this to
your advantage and make music NOT loop properly to get a sort-of infinite
length song!
Pattern loops are governed with a negative command word with the value of
-128 followed by the identical loop values (minus one) as two bytes - Eg 9,9
giving nine loops followed by a word containing the offset to the start of
the pattern to be looped. Remember, that looping THREE times means that the
section will play ONCE, then loop THREE times (so you hear it four times).
There is a maximum of 256 loops.
An example:
dc.w -128 Signal pattern loop.
dc.b 3,3 Loop 3 times. Remember, pair those loops!
dc.w 40 Loop back 40 bytes from here. The loop offset.
... Continues here after 3 loops.
The above shows a 40 byte pattern being looped 3 times (+1 played).
When it jumps back, it subtracts the loop offset value from the address where
the loop offset is. To clarify, here's a pattern repeat command that will
loop back on itself and therefore stay doing that forever!
dc.w -128 Signal pattern loop.
dc.w 1,1 Loop once (no matter - this example will loop forever!).
dc.w 4 Loop back 4 bytes from here.
When a pattern has looped the required amount of times, it will 'fall though'
and continue on to the next command word.
Bits & bobs:
There are 10 bits (10 commands) left in the command word. These bits are
reserved for future versions; planned are:
Volume control.
Flange and digital distortion effects.
Echo/room/hall/crossfade effects.
Digital filtering.
Infinite note range.
All these features are NOT in this version simply because of speed and use.
When the right hardware comes along (like Atari's new Jaguar - we're hoping
that Atari have the good sense of making a computer out of it), or we figure
a way of doing any of the above without slowing Mr Music down too much.
A command word containing the word value -9999 will signify the end of
that channel's song and will loop back to the start of the channel data.
NOTE:
When a new note or slide is performed, the sample is not re-started. This is
because of the end-sustain feature, where you can play a new note on a looped
sample without making it play from the start (this allows you to do some very
nice effects without a 'key release'). For example, say you have a looped
sample that is someone's voice saying "HELLO YOU" and when it loops it says
"YOU YOU YOU YOU..." and so on. When you play a new note, it will play from
the "YOU YOU..." point, NOT from the start of the sample. If you DO want the
slide or note to be in effect from the START of the sample (as in from the
"HELLO..." point) then you signal a NEW SAMPLE with the sample value. This
allows you flexibility - you can play the sample from the start, or continue
from the current point (yay!).
Here's an example 4-channel song (note that all the other 3 channels are
empty, thus filled with a rest of 1 unit). This is what a basic .SNG file
would look like.
CHANNEL 1.
dc.w %0100000000000011 Play new sample (looped) and note.
dc.w 0 Sample number (0 = first sample).
dc.w 63 Note (63 is highest).
dc.w 50 Duration (50 units = 1 second at 50Hz).
dc.w -128 Pattern loop.
dc.b 3,3 Loop three times.
dc.w 12 12 bytes back from here.
dc.w %0100000000000100 Slide current note.
dc.w 31 To note 31 (middle).
dc.w 1 Speed.
dc.w 40 Duration.
dc.w %0100000000000101 Slide from sample start.
dc.w 0 Sample number.
dc.w 40 To note 40.
dc.w 2 Speed.
dc.w 80 Duration.
dc.w -9999 END OF CHANNEL 1.
CHANNEL 2.
dc.w %0000000000001000 Rest.
dc.w 1 Duration of 1 unit.
dc.w -9999 END OF CHANNEL 2.
CHANNEL 3.
dc.w %0000000000001000 Rest.
dc.w 1 Duration of 1 unit.
dc.w -9999 END OF CHANNEL 3.
CHANNEL 4.
dc.w %0000000000001000 Rest.
dc.w 1 Duration of 1 unit.
dc.w -9999 END OF CHANNEL 4.
The above will play a few notes & slides on channel 1, while the other
channels are quiet (it doesn't matter that all the channels loop at the same
point, since only one channel is heard). Note that any empty channels need
to be filled with a rest (of any duration).
SECTION 3 - .EIT file structure.
Right, here's the sample (.EIT) file structure.
NOTE: One of the principal speed factors of Mr Music is because of a naughty
trick The Phantom did with the sample ends (lately, it seems, people have
been using this technique for their trackers... Wonder why??!!). You NEED
to do this 'trick' otherwise the sample playback will not work plroperly.
The one problem this has is that your samples are 1.4 K longer. Yikes! When
you have a lot of samples (even if they are 128 bytes each) then expect the
size to grow. The reason is:
Each sample has 1400 bytes (1.4K) tagged on at the end of it. This is done
so the player has to do NO loop/end checks (saving about 10% CPU time or
more!!!). If the sample has no loop, then you tag onto the end of it null
bytes with the value 128 (or any value but this works best) - remember, 1400
bytes of null data. If it DOES have a loop, then tag 1400 bytes FROM the
loop start. Say the sample is 4096 bytes long and the loop is at 230 bytes.
Then you tag 1400 bytes from start_of_sample+230 bytes. A problem arises
when the loop point to the end of the sample is less than 1400 bytes in
length. In this case, you keep copying from the loop pointer until you reach
1400 bytes (E.G. If the sample loop is at 23 bytes from the start of the
sample and there's only 60 bytes from there to the end of the sample) you
copy 37 (60-23) byte blocks until you reach 1400 bytes copied).
With small samples with no loop, there's none of this since you merely tag on
1400 bytes of null data.
Note that the maximum length of a sample is 64K (65535 bytes).
Data structure:
The first 'block' (of two) contains the sample offsets, lengths and loop
points. The second 'block' contains the actual samples.
In the first 'block' the data is as follows.
A LONGWORD (4-byte value) containing this instrument's offset from the end of
this block. This is very simple to work out. Just get the sample's address
and subtract it from the address of the start of your sample block. Simple
as that!
A WORD (2-byte value) containing the sample length.
A WORD (2-byte value) containing thhe sample loop point (=0 if none).
... This continues for the number of instruments you have and then to signal
the end of the block you put in a negative WORD (2-byte value) as the sample
offset (for example, a -9999). Immediately after that the sample data
starts; note that you do not need to mark the end of the sample data block.
To make things clearer, here's a little assembly listing to help you. It
does not have any 68000 code, so it should be pretty simple!
slist: dc.l bdru-soffs <- Sample offset (note the calculation)..
dc.w 1848,0
| |_________ Sample loop (none here, so zero).
|_____________ Sample length.
That's the first instrument... We have more, so we continue...
dc.l snar-soffs
dc.w 2156,0
dc.l hhop-soffs
dc.w 2621,0
dc.l orga-soffs
dc.w 4886,319
dc.l synt-soffs
dc.w 14701,0
dc.l wobb-soffs
dc.w 6101,2428
dc.l stre-soffs
dc.w 4886,913
dc.l panf-soffs
dc.w 12936,4754
dc.l hhop-soffs
dc.w 2621,0
dc.l bas2-soffs
dc.w 6875,0
dc.l solo-soffs
dc.w 3811,0
dc.l brig-soffs
dc.w 4170,0
dc.l barr-soffs
dc.w 5280,0
dc.l mono-soffs
dc.w 4900,0
dc.l funk-soffs
dc.w 3932,0
dc.l maxb-soffs
dc.w 1694,517
dc.w -9999 <- Finally, the terminator word.
Right, and now the samples. INCBIN for those non-assembler types is a
command used in the assembler to load in a binary file (like a picture).
soffs: <- We use this 'address' to get the sample offsets.
bdru: incbin bdru.spl
snar: incbin snar.spl
hhop: incbin hhop.spl
orga: incbin orga.spl
synt: incbin synt.spl
wobb: incbin wobb.spl
stre: incbin stre.spl
panf: incbin panf.spl
bas2: incbin bas2.spl
solo: incbin solo.spl
brig: incbin brig.spl
barr: incbin barr.spl
mono; incbin mono.spl
funk: incbin funk.spl
maxb: incbin maxb.spl
SECTION 4 - THE END.
Right, if you have any problems or questions, then either contact The Phantom
via Contact BBS (details above), or via mail:
The Phantom
21 Bledlow House
Capland Street
London
NW8 8RU
ENGLAND
Please note that if you want anything on disk/s, send the required disk/s so
that poor Phantom can put the software on them.
Members of Electronic Images are:
Gizmo
The Phantom
Nightowl
Count Zero
Griff
Master
This has been an Electronic Images production!