-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecycle-rex1.tcl
88 lines (78 loc) · 1.65 KB
/
recycle-rex1.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# REX Loop Recycle 1 File Format
#
# - Chunks are IFF atoms, specifically this is an AIFF file.
big_endian
requires 0 "46 4F 52 4D" ;# FORM / Format
requires 8 "41 49 46 46" ;# AIFF
proc pad2 {size} {
set padding [expr {$size % 2}]
if {$padding > 0} {
entry "zeroPadding" "" $padding
move $padding
}
}
proc str {name} {
set length [uint32]
if {$length > 0} {
ascii $length $name
}
}
proc chunk {} {
section "Chunk" {
set magic [ascii 4 "magic"]
set length [uint32 "length"]
switch $magic {
"SSND" {
sectionname "SSND"
uint32 "relativeOffset"
uint32 "absoluteOffset"
bytes [expr $length - 8] "data"
}
}
}
}
proc category { length } {
set maxPos [expr [pos] + $length]
set categoryType [ascii 4 "categoryType"]
sectionname "Category: $categoryType"
while {[pos] < $maxPos} {
chunk
}
}
set magic [ascii 4 "chunkID"]
set fileLength [uint32 "fileLength"]
set fileType [ascii 4 "fileType"]
while {![end]} {
section "Chunk"
set chunk_id [ascii 4 "Chunk ID"]
set chunk_size [uint32 "Chunk Size"]
switch $chunk_id {
"SSND" {
sectionname "SSND (Sound Data)"
bytes $chunk_size "data"
}
"APPL" {
sectionname "APPL (Application Chunk)"
bytes $chunk_size "data"
}
"INST" {
sectionname "INST (Instrument Chunk)"
bytes $chunk_size "data"
}
"MARK" {
sectionname "MARK (Marker Chunk)"
bytes $chunk_size "data"
}
"COMM" {
sectionname "COMM (Common Chunk)"
uint16 "Num Channels"
uint32 "Num Sample Frames"
uint16 "Sample Size"
hex 10 "Sample Rate"
}
default {
bytes $chunk_size "data"
}
}
endsection
}