The SND-Sound Format
Translation provided by Ko.
What format is the data of the
sound file XXX.SND in?
I have analyzed the sound file XXX.SND used in Ruputer
(^_^)v. Is it of any help for the programming of utilities to figure
out the formats of the tempo data and the first half of the note data?
The followings are the outcomes of my analysis up to the present.
<I could solve the mistery of the data format of the
first half of the tempo data (^_^)v> ('98.7.21)
Finally, I solved the last
mistery, the data format of the first
half of the tempo (^_^)v It is only speculative, though..... (^_^;
<I found two different types of
formats of the data of the musical notes and rests.>
('98.7.20)
When I was testing the beta program of "RupSound" which Mr. Arataku
had made, I found that there are more than one "format type of the musical notes
and rests"; thereby I had him make necessary corrections for them in a
hurry. With a feat of strength (^_^;, I examined the relation between
the data of notes and the tempo and found the followings: ( 1 ) There are two kinds of formats
for the first half data of the musical notes and
rests. ( 2 ) The two formats can be
discerned by checking if the initial byte of the second half of the tempo data
is "00" or "02." ( 3 ) The first half
of the data format of the musical notes and rests shows the duration of the
physical sound. These are the hypotheses which I have made. I will
explain on the details of these hypotheses below.
<A part of the format of the tempo data was
understood.> ('98.7.17)
I have found the way to understand the speed of the tempo, which is as
follows: The last two bytes of the second half of the data show the speed of
the tempo. As they are handling two-byte long data, the upper byte and the
lower byte changes their positions on the memory.
For examples, "XX XX 80 02" -> "0280(H)" -> "640"
"XX XX 78 00" -> "0078(H)" -> "120"
Therefore, these
two bytes in the second half explain the speed of the tempo.
<Corrections of my mistakes. m(_._)m>
('98.7.17 added)
In the list of the tempo data, 3 0
07 00 10 00 00 00 1F 00
should be 07 00 10 00 00 00 1E 00. 2 1 4
07 00 03 00 07 00 03 00
should be 07 00 03 00 02 00 D6 00. I copied
them wrong. 4 8 Data for this were omitted by
mistake. I apologize for any possible troubles caused by these mistakes of
mine.
<File size>('98.6.25 added)
When I made a big piece of
music, the PC utility "Sound creation" returned an error
massage "最後の音符1個が書けませんでした。" [which means "The last
one note could not be written."] When I checked the size of the file which
had been written, the size was "2,046
bytes." As one musical note takes 4 bytes to 7 bytes of data
space, "2,048 bytes"
might be the maximum limit. Therefore, please be
careful of this when you make big pieces of music.
<Data sequence>
The data sequence of the sound file is as follows:
07 00 xx xx |
xx xx |
xx xx |
...... |
FF FF |
xx 00 xx xx |
xx xx |
xx xx |
... |
FF FF |
tempo (first half) |
pitch |
note |
note |
pitch |
|
|
tempo (second half) |
pitch |
note |
pitch |
note |
|
|
The initial 4 bytes show the data on the tempo, and then a pitch (1 byte) + a
note (1 byte) combination follows, corresponding to one sound (musical symbol)
except for the cases of the 1/2 note and parts of the whole note. The 1/2
note and parts of the whole note are expressed using a couple of numbers of the
sets of a pitch (1 byte) + a note (1 byte). These data continue to the
terminator "FF FF" (2 bytes). After this, the initial 4 bytes show the data
on the tempo, and then a pitch (1 byte) + a note (1 byte) combination follows,
corresponding to one sound (musical symbol).
The second half of the data
are expressed as a pitch (1 byte) + a note (1 byte) combination correspondind to
one sound (musical symbol), irrespective of the kinds of notes. The
terminator "FF FF" (2 bytes) shows the last of the data.
For examples, in the case of "tempo 120, c4 (do), 1/4 note, e5 (mi), 1/2
note," the data are as follows:
07 00 04 00 |
1A 38 |
2A 30 |
FF FF |
00 00 78 00 |
1A 0A |
2A 0E |
FF FF |
tempo (first half) |
pitch |
note |
note |
pitch |
|
tempo (second half) |
pitch |
note |
pitch |
note |
|
<tempo> ('98.7.21
added)
The tempo data consist of the first 4 bytes and the latter 4 bytes. The
contents of their data vary depending on the kind of tempo.
- The third byte shows the clock number to define the physical speed of the
tempo.
- The first byte in the second half defines the number of clocks of the 1/4
note. "00" shows 8 clocks and "02" shows 6 clocks.
- From 1 and 2, we get the speed of the tempo by using the following
equation.
- tempo = 3,840 /("clock number in 1" x "number of clocks of the 1/4
note")
- The 3rd and 4th bytes in the second half show the number of the tempo.
- "1F 00" -> "00 1F" -> 30
- "E0 10" -> "10 E0" -> 480
tempo |
data |
physical speed |
expressed |
first |
second |
3rd byte |
1/4 note |
calculated |
3&4th bytes |
30 |
07 00 10 00 |
00 00 1F 00 |
16 |
8 |
30 |
30 |
32 |
07 00 0F 00 |
00 00 20 00 |
15 |
8 |
32 |
32 |
34 |
07 00 0E 00 |
00 00 22 00 |
14 |
8 |
34 |
34 |
36 |
07 00 12 00 |
02 00 24 00 |
18 |
6 |
36 |
36 |
38 |
07 00 0D 00 |
00 00 26 00 |
13 |
8 |
37 |
38 |
40 |
07 00 0C 00 |
00 00 28 00 |
12 |
8 |
40 |
40 |
44 |
07 00 0B 00 |
00 00 2C 00 |
11 |
8 |
44 |
44 |
46 |
07 00 0E 00 |
02 00 2E 00 |
14 |
6 |
46 |
46 |
48 |
07 00 0A 00 |
00 00 30 00 |
10 |
8 |
48 |
48 |
50 |
07 00 0D 00 |
02 00 32 00 |
13 |
6 |
49 |
50 |
54 |
07 00 09 00 |
00 00 36 00 |
9 |
8 |
53 |
54 |
58 |
07 00 0B 00 |
02 00 3A 00 |
11 |
6 |
58 |
58 |
60 |
07 00 08 00 |
00 00 3C 00 |
8 |
8 |
60 |
60 |
64 |
07 00 0A 00 |
02 00 40 00 |
10 |
6 |
64 |
64 |
70 |
07 00 07 00 |
00 00 46 00 |
7 |
8 |
69 |
70 |
72 |
07 00 09 00 |
02 00 48 00 |
9 |
6 |
71 |
72 |
80 |
07 00 06 00 |
00 00 50 00 |
6 |
8 |
80 |
80 |
92 |
07 00 07 00 |
02 00 5C 00 |
7 |
6 |
91 |
92 |
96 |
07 00 05 00 |
00 00 60 00 |
5 |
8 |
96 |
96 |
108 |
07 00 06 00 |
02 00 6C 00 |
6 |
6 |
107 |
108 |
120 |
07 00 04 00 |
00 00 78 00 |
4 |
8 |
120 |
120 |
128 |
07 00 05 00 |
02 00 80 00 |
5 |
6 |
128 |
128 |
160 |
07 00 03 00 |
00 00 A0 00 |
3 |
8 |
160 |
160 |
214 |
07 00 03 00 |
02 00 D6 00 |
3 |
6 |
213 |
214 |
240 |
07 00 02 00 |
00 00 F0 00 |
2 |
8 |
240 |
240 |
320 |
07 00 02 00 |
02 00 40 01 |
2 |
6 |
320 |
320 |
480 |
07 00 01 00 |
00 00 E0 01 |
1 |
8 |
480 |
480 |
640 |
07 00 01 00 |
02 00 80 02 |
1 |
6 |
640 |
640 |
<Pitch> from b3 to c8
The pitch is shown by the first byte in the sound data (a combination of a
pitch [1 byte] + a note [1 byte]). There are pitches ranging from the lowest
b3 (si) to c8 (do) over 4 octaves. The musical rests are expressed as 56.
|
do |
do# |
re |
re# |
mi |
fa |
fa# |
sol |
sol# |
la |
la# |
si |
do 8c |
c |
c# |
d |
d# |
e |
f |
f# |
g |
g# |
a |
a# |
b |
3 |
|
|
|
|
|
|
|
|
|
|
|
19 |
4 |
1A |
1B |
1C |
1D |
1E |
1F |
20 |
21 |
22 |
23 |
24 |
25 |
5 |
26 |
27 |
28 |
29 |
2A |
2B |
2C |
2D |
2E |
2F |
30 |
31 |
6 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
3A |
3B |
3C |
3D |
7 |
3E |
3F |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
4A |
<Note & rest> ('98.7.20 added ) The data for notes and rests
are divided into the first half and the second half. Each datum in the second
half corresponds with each sound (musical symbol), and the sequence of order of
the data is the same as sequence of the symbols in the PC utility "Sound
creation."
The data in the first half probably show the physical duration of the
sound. I assume that there are two separate tables of the durations of the
notes for the two separate series of the tempo speeds, because we can not use a
single number and get successful division--the divisible numbers differ among
different speeds of the tempos. As for the discrimination of the two tables,
we use the first table if the first byte in the second half of the tempo data is
"00," or we use the second table if it is "02."
(1) For the tempos "00 00 XX XX" (30, 32, 34, 38, 40, 44, 48, 54, 60, 70, 80,
96, 120, 160, 240, 480)
|
1/32 note |
1/16 note |
1/8 note |
1/4 note |
1/2 note |
whole note |
first |
second |
first |
second |
first |
second |
first |
second |
first |
second |
first |
second |
|
31 |
00 |
32 |
02 |
34 |
06 |
38 |
0A |
30 |
0E |
40 30 |
11 |
dotted |
|
|
33 |
03 |
36 |
07 |
3C |
0B |
40 38 |
0F |
40 40 30 |
12 |
double-dotted |
|
|
33 |
04 |
37 |
08 |
3E |
0C |
40 3C |
10 |
40 40 40 38 |
13 |
triplet |
31 |
01 |
31 |
05 |
33 |
09 |
35 |
0D |
|
|
|
|
|
1/32 rest |
1/16 rest |
1/8 rest |
1/4 rest |
1/2 rest |
whole rest |
first |
second |
first |
second |
first |
second |
first |
second |
first |
second |
first |
second |
|
01 |
64 |
02 |
66 |
04 |
6A |
08 |
6E |
00 |
72 |
00 00 |
75 |
dotted |
|
|
03 |
67 |
06 |
6B |
0C |
6F |
00 08 |
73 |
00 00 00 |
76 |
double-dotted |
|
|
03 |
68 |
07 |
6C |
0E |
70 |
00 0C |
74 |
00 00 00 08 |
77 |
triplet |
01 |
65 |
01 |
69 |
03 |
6D |
05 |
71 |
|
|
|
|
(2) For the tempos "02 00 XX XX" (36, 46, 50, 58, 64, 72, 92, 108, 128,
214, 320, 640)
|
1/32 note |
1/16 note |
1/8 note |
1/4 note |
1/2 note |
whole note |
first |
second |
first |
second |
first |
second |
first |
second |
first |
second |
first |
second |
|
31 |
00 |
31 |
02 |
33 |
06 |
36 |
0A |
3C |
0E |
40 38 |
11 |
dotted |
|
|
32 |
03 |
34 |
07 |
39 |
0B |
40 32 |
0F |
40 40 34 |
12 |
double-dotted |
|
|
33 |
04 |
35 |
08 |
3A |
0C |
40 35 |
10 |
40 40 3A |
13 |
triplet |
31 |
01 |
31 |
05 |
32 |
09 |
34 |
0D |
|
|
|
|
|
1/32 rest |
1/16 rest |
1/8 rest |
1/4 rest |
1/2 rest |
whole rest |
first |
second |
first |
second |
first |
second |
first |
second |
first |
second |
first |
second |
|
01 |
64 |
01 |
66 |
03 |
6A |
06 |
6E |
0C |
72 |
00 08 |
75 |
dotted |
|
|
02 |
67 |
04 |
6B |
09 |
6F |
00 02 |
73 |
00 00 04 |
76 |
double-dotted |
|
|
03 |
68 |
05 |
6C |
0A |
70 |
00 05 |
74 |
00 00 0A |
77 |
triplet |
01 |
65 |
01 |
69 |
02 |
6D |
04 |
71 |
|
|
|
|
Speculating from these, the data in the first half seems to show the
rough physical duration of the sound. The followings are the data in the
order of the duration of the sound starting from the shortest duration.
notation |
tempo (1) |
tempo (2) |
note (1) |
rest (1) |
duration (1) |
note (2) |
rest (2) |
duration (2) |
triplet 1/32 |
31 |
01 |
1 |
31 |
01 |
1 |
1/32 |
31 |
01 |
1 |
31 |
01 |
1 |
triplet 1/16 |
31 |
01 |
1 |
31 |
01 |
1 |
1/16 |
32 |
02 |
2 |
31 |
01 |
1 |
triplet 1/8 |
33 |
03 |
3 |
32 |
02 |
2 |
dotted 1/16 |
33 |
03 |
3 |
32 |
02 |
2 |
double dotted 1/16 |
33 |
03 |
3 |
33 |
03 |
3 |
1/8 |
34 |
04 |
4 |
33 |
03 |
3 |
triplet 1/4 |
35 |
05 |
5 |
34 |
04 |
4 |
dotted 1/8 |
36 |
06 |
6 |
34 |
04 |
4 |
double-dotted 1/8 |
37 |
07 |
7 |
35 |
05 |
5 |
1/4 |
38 |
08 |
8 |
36 |
06 |
6 |
dotted 1/4 |
3C |
0C |
12 |
39 |
09 |
9 |
double-dotted 1/4 |
3E |
0E |
14 |
3A |
0A |
10 |
1/2 |
30 |
00 |
16 |
3C |
0C |
12 |
dotted 1/2 |
40 38 |
00 08 |
22 |
40 32 |
00 02 |
18 |
double-dotted 1/2 |
40 3C |
00 0C |
28 |
40 35 |
00 05 |
21 |
whole |
40 30 |
00 00 |
32 |
40 38 |
00 08 |
24 |
dotted whole |
40 40 30 |
00 00 00 |
48 |
40 40 34 |
00 00 04 |
36 |
double-dotted whole |
40 40 40 38 |
00 00 00 08 |
56 |
40 40 3A |
00 00 0A |
42 |
- The data in the lowest 4 bits are meaningful.
- "0" is regarded to be 16.
- Preceding "X0"s mean 16 to be added. ( X0 X0 X0 08 = 16+16+16+8=56)
If my hypotheses are correct, the shorter notes can not be discriminated
against each other; am I right?
|