The cl-riff Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The cl-riff Reference Manual

This is the cl-riff Reference Manual, version 0.0.2, generated automatically by Declt version 4.0 beta 2 "William Riker" on Thu Sep 15 04:07:15 2022 GMT+0.

Table of Contents


1 Introduction

cl-riff

The Resource Interchange File Format (RIFF) is a generic file container format for storing data in tagged chunks. It is primarily used to store multimedia such as sound and video, though it may also be used to store any arbitrary data.

I wrote this code as a cross-platform way of processing WAV audio files. (See cl-wav).

Use read-riff-file to load a whole file, returning it's content as a list of chunks, where each chunk is a plist.

Alternatively, open the stream yourself and call read-chunk successively until NIL.

Chunks are represented as plists, with accessor methods defined for chunk-id, chunk-data-size, chunk-data and file-type.

Example

> (ql:quickload :cl-riff)
> (riff:read-riff-file "c:/windows/media/ding.wav")
...
> (riff:riff-file-type (first *))
"WAVE"

> (riff:write-riff-file (riff:read-riff-file "c:/windows/media/ding.wav")
                        "c:/windows/media/ding-copy.wav")

References

Resource Interchange File Format, Wikipedia

Resource Interchange File Format Services, MSDN

Resource Interchange File Format (RIFF), MSDN

Resource Interchange File Format (RIFF)

Inside the RIFF Specification

RIFF File Structure

Contributors

Write functionality by Patrick Stein. RIFX and XFIR detection and reading by Devon Sean McCullough.


2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 cl-riff

Reads Resource Interchange File Format (RIFF) files.

Author

Rob Blackwell

Version

0.0.2

Dependency

alexandria (system).

Source

cl-riff.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp   [Contents][Index]

3.1.1 cl-riff/cl-riff.asd

Source

cl-riff.asd.

Parent Component

cl-riff (system).

ASDF Systems

cl-riff.


3.1.2 cl-riff/package.lisp

Source

cl-riff.asd.

Parent Component

cl-riff (system).

Packages

riff.


3.1.3 cl-riff/riff.lisp

Dependency

package.lisp (file).

Source

cl-riff.asd.

Parent Component

cl-riff (system).

Public Interface
Internals

Previous: , Up: Lisp   [Contents][Index]

3.1.4 cl-riff/write.lisp

Dependency

riff.lisp (file).

Source

cl-riff.asd.

Parent Component

cl-riff (system).

Public Interface
Internals

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 riff

Source

package.lisp.

Use List
  • alexandria.
  • common-lisp.
Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Public Interface


5.1.1 Ordinary functions

Function: default-chunk-data-reader (stream chunk-id chunk-data-size)

Reads chunk-data from STREAM as an array of CHUNK-DATA-SIZE bytes. Second argument CHUNK-ID is ignored.

Package

riff.

Source

riff.lisp.

Function: default-chunk-data-writer (chunk-id chunk-data stream &key start end)

Writes chunk-data as an array of bytes.

Package

riff.

Source

write.lisp.

Function: find-riff-chunk (stream chunk-id &key chunk-data-reader format)

Reads chunks from stream until a chunk with chunk-id is found, or nil meaning not found. Optional keyword FORMAT defaults to nil to detect the format from the file, otherwise :riff, :rifx or :xfir to specify the format.

Package

riff.

Source

riff.lisp.

Function: read-riff-chunk (stream &key chunk-data-reader format)

Read a riff file chunk from STREAM and return it as a plist or nil if end of file. Optional keyword FORMAT nil to accept "RIFF", "RIFX" or "XFIR"
as the chunk id and process accordingly; otherwise :riff (default), :rifx or :xfir to specify the format. Chunks and subchunks are returned indiscriminately - discerning subchunk structure is up to the caller. First returned value is a plist keyed by :chunk-id, :chunk-data-size and either :file-type or :chunk-data. Second returned value is the actual format as a keyword.

Package

riff.

Source

riff.lisp.

Function: read-riff-chunks (stream &key chunk-data-reader format)

Reads all the chunks from STREAM until end of file. Returns a list of chunks. Optional keyword FORMAT defaults to nil to detect the format from the stream, otherwise :riff, :rifx or :xfir to specify the format.

Package

riff.

Source

riff.lisp.

Function: read-riff-file (filespec &key chunk-data-reader format)

Reads a riff format file named by FILESPEC, returning a list of chunks. Optional keyword FORMAT defaults to nil to detect the format from the file, otherwise :riff, :rifx or :xfir to specify the format.

Package

riff.

Source

riff.lisp.

Function: read-u2 (stream)

Reads a 2 byte little-endian integer from STREAM.

Package

riff.

Source

riff.lisp.

Function: read-u2* (stream)

Reads a 2 byte big-endian integer from STREAM.

Package

riff.

Source

riff.lisp.

Function: read-u4 (stream)

Reads a 4 byte little-endian integer from STREAM.

Package

riff.

Source

riff.lisp.

Function: read-u4* (stream)

Reads a 4 byte big-endian integer from STREAM. Used with rifx and xfir formats.

Package

riff.

Source

riff.lisp.

Function: write-riff-chunk (chunk-id chunk-data stream &key chunk-data-writer start end)

Writes a riff file chunk to stream.

Package

riff.

Source

write.lisp.

Function: write-riff-chunks (chunks stream &key chunk-data-writer)

Writes all the chunks to stream.

Package

riff.

Source

write.lisp.

Function: write-riff-file (chunks filespec &key chunk-data-writer)

Writes a RIFF format file named by filespec from the given chunks.

Package

riff.

Source

write.lisp.

Function: write-u2 (u2 stream)

Writes a 2 byte little-endian integer to stream.

Package

riff.

Source

write.lisp.

Function: write-u4 (u4 stream)

Writes a 4 byte little-endian integer to stream.

Package

riff.

Source

write.lisp.


5.1.2 Generic functions

Generic Function: riff-chunk-data (chunk)

Returns a byte array being the data in the riff CHUNK.

Package

riff.

Source

riff.lisp.

Methods
Method: riff-chunk-data ((chunk cons))
Generic Function: riff-chunk-data-end (chunk)
Package

riff.

Methods
Method: riff-chunk-data-end (chunk)
Source

riff.lisp.

Generic Function: riff-chunk-data-size (chunk)

Returns the size of the riff CHUNK data.

Package

riff.

Source

riff.lisp.

Methods
Method: riff-chunk-data-size ((chunk cons))
Generic Function: riff-chunk-data-start (chunk)
Package

riff.

Methods
Method: riff-chunk-data-start ((chunk cons))
Source

riff.lisp.

Generic Function: riff-chunk-id (chunk)

Returns the chunk-id of a riff CHUNK - a four character ascii tag.

Package

riff.

Source

riff.lisp.

Methods
Method: riff-chunk-id ((chunk cons))
Generic Function: riff-file-type (chunk)

Returns a four character riff file type - e.g. "WAVE"

Package

riff.

Source

riff.lisp.

Methods
Method: riff-file-type ((chunk cons))

5.2 Internals


Previous: , Up: Internals   [Contents][Index]

5.2.1 Ordinary functions

Function: read-fourcc (stream)

Reads a four character tag (fourcc) from STREAM and returns it as an ascii string. Returns nil at end of file.

Package

riff.

Source

riff.lisp.

Function: read-fourcc* (stream)

Reads a four character tag (fourcc) from STREAM and returns it as a reversed ascii string. Returns nil at end of file.
Used with xfir format.

Package

riff.

Source

riff.lisp.

Function: write-fourcc (fourcc stream)

Writes a four character tag (FOURCC) to stream.

Package

riff.

Source

write.lisp.

Function: write-riff-section (chunk-id section-type chunk-data-size stream)

Writes a riff subsection header to stream.

Package

riff.

Source

write.lisp.


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   D   F   G   M   R   W  
Index Entry  Section

D
default-chunk-data-reader: Public ordinary functions
default-chunk-data-writer: Public ordinary functions

F
find-riff-chunk: Public ordinary functions
Function, default-chunk-data-reader: Public ordinary functions
Function, default-chunk-data-writer: Public ordinary functions
Function, find-riff-chunk: Public ordinary functions
Function, read-fourcc: Private ordinary functions
Function, read-fourcc*: Private ordinary functions
Function, read-riff-chunk: Public ordinary functions
Function, read-riff-chunks: Public ordinary functions
Function, read-riff-file: Public ordinary functions
Function, read-u2: Public ordinary functions
Function, read-u2*: Public ordinary functions
Function, read-u4: Public ordinary functions
Function, read-u4*: Public ordinary functions
Function, write-fourcc: Private ordinary functions
Function, write-riff-chunk: Public ordinary functions
Function, write-riff-chunks: Public ordinary functions
Function, write-riff-file: Public ordinary functions
Function, write-riff-section: Private ordinary functions
Function, write-u2: Public ordinary functions
Function, write-u4: Public ordinary functions

G
Generic Function, riff-chunk-data: Public generic functions
Generic Function, riff-chunk-data-end: Public generic functions
Generic Function, riff-chunk-data-size: Public generic functions
Generic Function, riff-chunk-data-start: Public generic functions
Generic Function, riff-chunk-id: Public generic functions
Generic Function, riff-file-type: Public generic functions

M
Method, riff-chunk-data: Public generic functions
Method, riff-chunk-data-end: Public generic functions
Method, riff-chunk-data-size: Public generic functions
Method, riff-chunk-data-start: Public generic functions
Method, riff-chunk-id: Public generic functions
Method, riff-file-type: Public generic functions

R
read-fourcc: Private ordinary functions
read-fourcc*: Private ordinary functions
read-riff-chunk: Public ordinary functions
read-riff-chunks: Public ordinary functions
read-riff-file: Public ordinary functions
read-u2: Public ordinary functions
read-u2*: Public ordinary functions
read-u4: Public ordinary functions
read-u4*: Public ordinary functions
riff-chunk-data: Public generic functions
riff-chunk-data: Public generic functions
riff-chunk-data-end: Public generic functions
riff-chunk-data-end: Public generic functions
riff-chunk-data-size: Public generic functions
riff-chunk-data-size: Public generic functions
riff-chunk-data-start: Public generic functions
riff-chunk-data-start: Public generic functions
riff-chunk-id: Public generic functions
riff-chunk-id: Public generic functions
riff-file-type: Public generic functions
riff-file-type: Public generic functions

W
write-fourcc: Private ordinary functions
write-riff-chunk: Public ordinary functions
write-riff-chunks: Public ordinary functions
write-riff-file: Public ordinary functions
write-riff-section: Private ordinary functions
write-u2: Public ordinary functions
write-u4: Public ordinary functions

Jump to:   D   F   G   M   R   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables