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
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
//! Reads wavetable files in WAV format.
//!
//! Currently WtReader only supports reading WAV files in float format,
//! containing the samples as 32-bit float values. Additionally each waveform
//! in the file must be 2048 samples long.
//!
//! For every 2048 samples, the reader will add an additional waveshape table
//! to the result. As read from disk, these tables will not be bandlimited,
//! and might therefore generate aliasing if used directly.

use super::{Wavetable, WavetableRef};
use super::Float;

use std::fs::File;
use std::io::{Read, BufReader};
use std::mem;

use log::{info, trace, warn};

#[repr(C, packed)]
#[derive(Debug, Copy, Clone)]
struct ChunkHeader {
    chunk_id: [u8; 4],
    size: u32
}

pub struct WtReader {
    pub base_path: String,
}

impl WtReader {
    /// Creates a new WtReader instance.
    ///
    /// The argument is a path to a directory that files will be read from.
    ///
    /// ```
    /// use wavetable::WtReader;
    ///
    /// let data_dir = "data".to_string();
    ///
    /// let reader = WtReader::new(&data_dir);
    /// ```
    pub fn new(path: &str) -> Self {
        let mut base_path = path.to_string();
        let path_bytes = base_path.as_bytes();
        if path_bytes[path_bytes.len() - 1] != b'/' {
            base_path.push('/');
        }
        WtReader{base_path: base_path}
    }

    /// Read a file with the given filename.
    ///
    /// The filename should not contain the full path of the file, but be
    /// relative to the base path set in the constructor.
    ///
    /// ``` norun
    /// use wavetable::WtReader;
    ///
    /// # fn main() -> Result<(), ()> {
    ///
    /// let reader = WtReader::new("data");
    /// let wavetable = reader.read_file("test")?;
    ///
    /// # Ok(())
    /// # }
    /// ```
    pub fn read_file(&self, filename: &str) -> Result<WavetableRef, ()> {
        if filename == "" {
            return Err(());
        }
        let filename = self.base_path.clone() + filename;
        let result = File::open(filename);
        if let Ok(file) = result {
            let reader = BufReader::new(file);
            WtReader::read_wavetable(reader, 2048)
        } else {
            Err(())
        }
    }

    /// Read a wavetable from the provided input stream.
    ///
    /// Source is any stream object implementing the Read trait.
    /// samples_per_table is the length of a single wave cycle, usually 2048.
    ///
    /// ``` norun
    /// use wavetable::WtReader;
    /// use std::io::BufReader;
    ///
    /// let reader = WtReader::new("data");
    /// let data: &[u8] = &[0x00]; // Some buffer with wave data
    /// let buffer = BufReader::new(data);
    /// let wavetable = WtReader::read_wavetable(buffer, 2048)?;
    /// ```
    pub fn read_wavetable<R: Read>(mut source: R, samples_per_table: usize) -> Result<WavetableRef, ()> {
        // Read RIFF header
        let result = WtReader::read_header(&mut source);
        match result {
            Ok(_header) => { WtReader::skip_chunk(&mut source, 4); }
            Err(()) => return Err(()),
        }
        // Read chunks
        loop {
            let result = WtReader::read_header(&mut source);
            match result {
                Ok(header) => {
                    unsafe { info!("Chunk ID: {:?}\nSize; {}", header.chunk_id, header.size) };
                    if header.chunk_id[0] == 'd' as u8
                    && header.chunk_id[1] == 'a' as u8
                    && header.chunk_id[2] == 't' as u8
                    && header.chunk_id[3] == 'a' as u8 {
                        // Found data section, create wavetable
                        let result = WtReader::read_samples(&mut source, header.size, samples_per_table);
                        let samples = if let Ok(s) = result { s } else { return Err(()) };
                        let num_tables = samples.len();
                        return Result::Ok(Wavetable::new_from_vector(num_tables, 1, samples_per_table, samples));
                    } else {
                        WtReader::skip_chunk(&mut source, header.size);
                    }
                }
                Err(()) => return Err(()),
            }
        }
    }

    // Read the header of the next WAV chunk from the input stream.
    fn read_header<R: Read>(source: &mut R) -> Result<ChunkHeader, ()> {
        let mut header: ChunkHeader = unsafe { mem::zeroed() };
        let header_size = mem::size_of::<ChunkHeader>();
        unsafe {
            let header_slize = std::slice::from_raw_parts_mut(&mut header as *mut _ as *mut u8, header_size);
            source.read_exact(header_slize).unwrap();
        }
        info!("\nRead structure: {:#?}", header);
        Ok(header)
    }

    // Skip over the rest of the current chunk to the next header.
    fn skip_chunk<R: Read>(source: &mut R, num_bytes: u32) {
        let mut buf: [u8; 1] = unsafe { mem::zeroed() };
        for _i in 0..num_bytes {
            source.read(&mut buf).unwrap();
        }
    }

    // Read samples into multiple tables.
    //
    // A file is assumed to hold multiple waveshapes, each with
    // <samples_per_table> values. One more value is added to the end of the
    // table automatically.
    //
    fn read_samples<R: Read>(source: &mut R, num_bytes: u32, samples_per_table: usize) -> Result<Vec<Vec<Float>>, ()> {
        let mut buf: f32 = unsafe { mem::zeroed() };
        let mut samples: Vec<Vec<Float>> = vec!{};
        let sample_size = mem::size_of::<f32>();
        let num_samples = num_bytes as usize / sample_size;
        let num_tables = num_samples / samples_per_table;
        if num_samples < samples_per_table || num_samples % samples_per_table != 0 {
            info!("Unexpected number of samples: {}", num_samples);
            return Err(());
        }
        info!("{} samples total, {} tables with {} values each", num_samples, num_tables, samples_per_table);
        for _i in 0..num_tables {
            samples.push(vec!(0.0; samples_per_table + 1));
        }
        unsafe {
            let sample = std::slice::from_raw_parts_mut(&mut buf as *mut _ as *mut u8, sample_size);
            for i in 0..num_tables {
                let table = &mut samples[i];
                for j in 0..samples_per_table {
                    source.read_exact(sample).unwrap();
                    table[j] = buf as Float;
                }
                table[samples_per_table] = table[0]; // Duplicate first entry as last entry for easy interpolation
                Wavetable::normalize(table);
            }
        }
        Ok(samples)
    }
}


// ----------------------------------------------
//                  Unit tests
// ----------------------------------------------

struct TestContext {
}

impl TestContext {
    pub fn new() -> Self {
        TestContext{}
    }

    pub fn test(&mut self, ptr: &[u8]) -> bool {
        let reader = BufReader::new(ptr);
        let result = WtReader::read_wavetable(reader, 512);
        match result {
            Ok(_) => true,
            Err(()) => false
        }
    }
}

#[test]
fn single_wave_can_be_read() {
    let mut context = TestContext::new();
    assert!(context.test(SINGLE_WAVE));
}

#[test]
fn partial_wave_is_rejected() {
    let mut context = TestContext::new();
    assert!(!context.test(PARTIAL_WAVE));
}

#[test]
fn base_path_is_set_up_correctly() {
    let wtr = WtReader::new("NoSlash");
    assert!(wtr.base_path == "NoSlash/".to_string());

    let wtr = WtReader::new("WithSlash/");
    assert!(wtr.base_path == "WithSlash/".to_string());
}

const PARTIAL_WAVE: &[u8] = &[
    // RIFF/ WAVE header
    'R' as u8, 'I' as u8, 'F' as u8, 'F' as u8,
    0x04, 0x00, 0x00, 0x00,
    'W' as u8, 'A' as u8, 'V' as u8, 'E' as u8,
    // Junk chunk
    'j' as u8, 'u' as u8, 'n' as u8, 'k' as u8,
    0x04, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00,
    // TODO: fmt chunk
    // data chunk
    'd' as u8, 'a' as u8, 't' as u8, 'a' as u8,
    0x10, 0x00, 0x00, 0x00,
    0xa0, 0xc4, 0xb8, 0xba,
    0xa0, 0x54, 0xfc, 0x3a,
    0xf0, 0x0f, 0xaa, 0x3b,
    0x54, 0x2f, 0x0a, 0x3c,
];

const SINGLE_WAVE: &[u8] = &[
    'R' as u8, 'I' as u8, 'F' as u8, 'F' as u8,
    0x04, 0x00, 0x00, 0x00,
    'W' as u8, 'A' as u8, 'V' as u8, 'E' as u8,
    // Junk chunk
    'j' as u8, 'u' as u8, 'n' as u8, 'k' as u8,
    0x04, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00,
    // TODO: fmt chunk
    // data chunk
    'd' as u8, 'a' as u8, 't' as u8, 'a' as u8,
    0x00, 0x08, 0x00, 0x00,
    0xa0, 0xc4, 0xb8, 0xba, 0xa0, 0x54, 0xfc, 0x3a,
    0xf0, 0x0f, 0xaa, 0x3b, 0x54, 0x2f, 0x0a, 0x3c, 0x9c, 0x35, 0x40, 0x3c, 0x48, 0x43, 0x76, 0x3c,
    0x2a, 0x33, 0x96, 0x3c, 0x18, 0xb3, 0xb1, 0x3c, 0x1c, 0x50, 0xcd, 0x3c, 0xc5, 0x82, 0xe8, 0x3c,
    0xa8, 0x39, 0x01, 0x3d, 0x33, 0xdc, 0x0d, 0x3d, 0x3e, 0x6d, 0x1a, 0x3d, 0x8e, 0x5e, 0x27, 0x3d,
    0x44, 0x7a, 0x34, 0x3d, 0x8b, 0x5b, 0x41, 0x3d, 0xb6, 0x98, 0x4d, 0x3d, 0x25, 0x41, 0x59, 0x3d,
    0x98, 0x12, 0x65, 0x3d, 0x3c, 0xb0, 0x71, 0x3d, 0x23, 0xf3, 0x7e, 0x3d, 0xef, 0xfa, 0x85, 0x3d,
    0x19, 0xda, 0x8b, 0x3d, 0x7c, 0x23, 0x91, 0x3d, 0xf7, 0x76, 0x96, 0x3d, 0x46, 0x6f, 0x9c, 0x3d,
    0xe8, 0xe9, 0xa2, 0x3d, 0x0e, 0x66, 0xa9, 0x3d, 0x0b, 0x3f, 0xaf, 0x3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0x43, 0x43, 0x3e,
    0x78, 0x1c, 0x45, 0x3e, 0x48, 0xe7, 0x46, 0x3e, 0x08, 0xbb, 0x48, 0x3e, 0x09, 0xbf, 0x4a, 0x3e,
    0xbd, 0xf1, 0x4c, 0x3e, 0xb0, 0x19, 0x4f, 0x3e, 0xc2, 0xd4, 0x50, 0x3e, 0xec, 0x6b, 0x52, 0x3e,
    0x1a, 0xf4, 0x53, 0x3e, 0xde, 0xb0, 0x55, 0x3e, 0x16, 0xb0, 0x57, 0x3e, 0x88, 0xa3, 0x59, 0x3e,
    0x82, 0x7f, 0x5b, 0x3e, 0xb9, 0x45, 0x5d, 0x3e, 0xde, 0x09, 0x5f, 0x3e, 0x42, 0xae, 0x60, 0x3e,
    0x6f, 0x42, 0x62, 0x3e, 0xde, 0xdf, 0x63, 0x3e, 0xba, 0x78, 0x65, 0x3e, 0x81, 0x43, 0x67, 0x3e,
    0xa2, 0xfb, 0x68, 0x3e, 0xc6, 0xa0, 0x6a, 0x3e, 0x61, 0x25, 0x6c, 0x3e, 0x4d, 0x9e, 0x6d, 0x3e,
    0x64, 0x2c, 0x6f, 0x3e, 0xe9, 0xb6, 0x70, 0x3e, 0xae, 0x53, 0x72, 0x3e, 0x24, 0xe5, 0x73, 0x3e,
    0x78, 0x85, 0x75, 0x3e, 0x0a, 0x1a, 0x77, 0x3e, 0x96, 0x96, 0x78, 0x3e, 0x63, 0xfa, 0x79, 0x3e,
    0x88, 0x36, 0x7b, 0x3e, 0xf4, 0x96, 0x7c, 0x3e, 0xa9, 0xee, 0x7d, 0x3e, 0x3d, 0x48, 0x7f, 0x3e,
    0x3b, 0x5a, 0x80, 0x3e, 0xa0, 0x16, 0x81, 0x3e, 0x6f, 0xd1, 0x81, 0x3e, 0x05, 0x86, 0x82, 0x3e,
    0xa8, 0x33, 0x83, 0x3e, 0xa2, 0xcb, 0x83, 0x3e, 0x32, 0x6e, 0x84, 0x3e, 0xa1, 0x10, 0x85, 0x3e,
    0x8f, 0xa5, 0x85, 0x3e, 0x05, 0x47, 0x86, 0x3e, 0x63, 0xe6, 0x86, 0x3e, 0x74, 0x81, 0x87, 0x3e,
    0x91, 0x1c, 0x88, 0x3e, 0x80, 0xb9, 0x88, 0x3e, 0x18, 0x47, 0x89, 0x3e, 0xbc, 0xdd, 0x89, 0x3e,
    0xbf, 0x7c, 0x8a, 0x3e, 0xce, 0x12, 0x8b, 0x3e, 0xcb, 0xaf, 0x8b, 0x3e, 0xea, 0x46, 0x8c, 0x3e,
    0xec, 0xd7, 0x8c, 0x3e, 0x72, 0x63, 0x8d, 0x3e, 0xd1, 0xde, 0x8d, 0x3e, 0x10, 0x48, 0x8e, 0x3e,
    0xcd, 0xbb, 0x8e, 0x3e, 0x02, 0x53, 0x8f, 0x3e, 0x50, 0xfc, 0x8f, 0x3e, 0xb5, 0xa4, 0x90, 0x3e,
    0x10, 0x23, 0x91, 0x3e, 0xa9, 0x8a, 0x91, 0x3e, 0xb3, 0xf0, 0x91, 0x3e, 0x0a, 0x63, 0x92, 0x3e,
    0xf9, 0xe3, 0x92, 0x3e, 0x3b, 0x65, 0x93, 0x3e, 0x99, 0xdf, 0x93, 0x3e, 0x7a, 0x5c, 0x94, 0x3e,
    0x20, 0xd7, 0x94, 0x3e, 0xfa, 0x3b, 0x95, 0x3e, 0x42, 0x98, 0x95, 0x3e, 0x4c, 0xf7, 0x95, 0x3e,
    0x8a, 0x5a, 0x96, 0x3e, 0xfc, 0xd8, 0x96, 0x3e, 0x26, 0x57, 0x97, 0x3e, 0xf6, 0xc6, 0x97, 0x3e,
    0xc6, 0x37, 0x98, 0x3e, 0xc6, 0xa5, 0x98, 0x3e, 0x2c, 0x01, 0x99, 0x3e, 0x44, 0x59, 0x99, 0x3e,
    0x72, 0xb0, 0x99, 0x3e, 0x00, 0x04, 0x9a, 0x3e, 0xe2, 0x6a, 0x9a, 0x3e, 0x5a, 0xd2, 0x9a, 0x3e,
    0x90, 0x31, 0x9b, 0x3e, 0xe0, 0x97, 0x9b, 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0x96, 0x85, 0x87, 0x3e,
    0x47, 0x3e, 0x87, 0x3e, 0xba, 0xed, 0x86, 0x3e, 0x3d, 0x96, 0x86, 0x3e, 0x14, 0x42, 0x86, 0x3e,
    0x14, 0xfb, 0x85, 0x3e, 0x77, 0xbb, 0x85, 0x3e, 0xd6, 0x7a, 0x85, 0x3e, 0xca, 0x38, 0x85, 0x3e,
    0x3d, 0xf3, 0x84, 0x3e, 0x40, 0xaa, 0x84, 0x3e, 0x7b, 0x59, 0x84, 0x3e, 0x87, 0x00, 0x84, 0x3e,
    0x48, 0xa7, 0x83, 0x3e, 0x58, 0x5a, 0x83, 0x3e, 0x04, 0x14, 0x83, 0x3e, 0x49, 0xce, 0x82, 0x3e,
    0x94, 0x89, 0x82, 0x3e, 0xf7, 0x44, 0x82, 0x3e, 0x8a, 0xfc, 0x81, 0x3e, 0x41, 0xb0, 0x81, 0x3e,
    0x40, 0x5b, 0x81, 0x3e, 0x2c, 0x05, 0x81, 0x3e, 0xef, 0xb2, 0x80, 0x3e, 0xdc, 0x63, 0x80, 0x3e,
    0x87, 0x14, 0x80, 0x3e, 0x42, 0x96, 0x7f, 0x3e, 0x11, 0x11, 0x7f, 0x3e, 0x8e, 0x85, 0x7e, 0x3e,
    0xd3, 0xdf, 0x7d, 0x3e, 0xca, 0x0e, 0x7d, 0x3e, 0x33, 0x3a, 0x7c, 0x3e, 0x77, 0x96, 0x7b, 0x3e,
    0xd8, 0x32, 0x7b, 0x3e, 0xee, 0xdc, 0x7a, 0x3e, 0x82, 0x56, 0x7a, 0x3e, 0x8b, 0x93, 0x79, 0x3e,
    0x5c, 0xba, 0x78, 0x3e, 0xe2, 0xfd, 0x77, 0x3e, 0x09, 0x64, 0x77, 0x3e, 0x10, 0xd9, 0x76, 0x3e,
    0x79, 0x49, 0x76, 0x3e, 0xac, 0xb9, 0x75, 0x3e, 0xfa, 0x27, 0x75, 0x3e, 0xa8, 0x90, 0x74, 0x3e,
    0x2e, 0xf2, 0x73, 0x3e,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