Resource Interchange File Format (RIFF)
1 Reading and Writing
read-riff
write-riff
2 Binary Classes
riff%
new
riff:  chunk%
new
riff:  list%
new
chunk-ref
fourcc
pad/  word
8.12

Resource Interchange File Format (RIFF)🔗ℹ

 (require binary-class/riff) package: binary-class-riff

This module provides utilities for reading and writing RIFF files.

1 Reading and Writing🔗ℹ

procedure

(read-riff [in])  (is-a?/c riff%)

  in : input-port? = (current-input-port)
(read-riff in dispatch)  (is-a?/c riff%)
  in : input-port?
  dispatch : (-> bytes? (or/c (subclass?/c riff%) #f))
Reads RIFF data from in and returns it. If dispatch is supplied, it must be a procedure accepting a four-byte chunk ID, and returning a subclass of riff% or #f if no special handling is required.

procedure

(write-riff v [out])  void?

  v : (is-a?/c riff%)
  out : output-port? = (current-output-port)
Writes the RIFF object v to out.

2 Binary Classes🔗ℹ

class

riff% : class?

  superclass: object%

  extends: binary<%>
The base type for all RIFF data.

constructor

(new riff% [id id] [size size])  (is-a?/c riff%)

  id : bytes?
  size : exact-nonnegative-integer?

class

riff:chunk% : class?

  superclass: riff%

Represents a raw chunk.

constructor

(new riff:chunk% 
    [data data] 
    ...superclass-args...) 
  (is-a?/c riff:chunk%)
  data : bytes?

class

riff:list% : class?

  superclass: riff%

Represents a list chunk.

constructor

(new riff:list%    
    [type type]    
    [chunks chunks]    
    ...superclass-args...)  (is-a?/c riff:list%)
  type : bytes?
  chunks : (listof (is-a?/c riff%))

method

(send a-riff:list chunk-ref id ...+)  (or/c (is-a?/c riff%) #f)

  id : bytes?
Returns the first sub-chunk with ID matching id. If multiple ids are supplied, they refer to nested sub-chunks.

value

fourcc : binary? = (bytestring 4)

A binary type for reading chunk IDs.

procedure

(pad/word type)  binary?

  type : binary?
Returns a binary type based on type, with padding to the nearest word.