Serveur © IRCAM - CENTRE POMPIDOU 1996-2005. Tous droits réservés pour tous pays. All rights reserved. |
This paper concentrates on recent extensions and applications of the well established SDIF Sound Description Interchange Format : SDIF selection is a standard way to access a part of an SDIF file. It allows users to select SDIF frames of a certain type and time, and certain parts of the matrix data. It can be appended to a file name, making it easy to use for command-line programs. Other applications include choosing output description types, or mapping them to display modes or actions, e.g., when converting from untyped legacy formats. Foreign programming language interfaces allow processing of SDIF data by languages other than C. Interfaces and support functions for Lisp (CLOS) and Matlab are presented. Dispatching file I/O is a new programming style to be supported by Ircam's SDIF library. Users of the library specify a set of callback functions each with an SDIF selection indicating the frames and matrices that should be passed to that callback. The library takes care of reading the file, and dispatches selected SDIF data to the appropriate callback(s). Writing works analogously. The applications described in this paper include utility programs for Unix and Macintosh for conversion, viewing, extracting, and merging of SDIF, the integration of SDIF into the widely used software-systems Additive, jMax, Max/MSP, Diphone, OpenMusic, and the synergetic effects induced. We propose an SDIF Frame Directory, which allows rapid random access to data at a given time in an SDIF file by recording the file position, type, time, and other information about each data frame in an SDIF file.
Seeing that SDIF, the open, portable, well-defined, extensible Sound Description Interchange Format [Wright, Chaudhary, Freed, Khoury & Wessel, 1999], is now well established and accepted within the computer music community, this paper concentrates on recent SDIF extensions and applications. Most of these are implemented in Ircam's and Cnmat's free SDIF libraries for Unix, Windows, and Macintosh that can be downloaded from http://www.ircam.fr/sdif and http://www.cnmat.berkeley.edu/SDIF.
The following sections are ordered to minimize forward references : Section 2 presents the SDIF selection, section 3 programming interfaces to the SDIF library, and section 4 new applications of SDIF. They are followed by a proposal for an SDIF frame directory in section 5, and conclusions in section 6.
SDIF files can contain aggregates of different sound descriptions for one or multiple sound objects, hence the need to address a subset of these. The SDIF selection defines a syntax convention to specify a part of the data of an SDIF file. For example, certain time ranges, certain streams, certain frame or matrix types, or certain rows or columns of the SDIF matrices can be selected. This selection specification can be conveniently added to a file name, so that command-line programs transparently inherit powerful selection capabilities. They only have to use a selection-aware SDIF library, such as Ircam's, which takes care of parsing and executing the selection. There are more applications for the SDIF selection syntax: It can choose the output description type of programs, or can map them to display modes or actions.
The syntax for a filename, possibly including the directory path, with an SDIF selection is :
[filename]::[#stream][:frame][/matrix][.column][_row][@time]
The start of the selection specification is marked by the last `::' occurring, followed by 6 optional selection elements. This way, there is no ambiguity with filenames containing the selection element markers. 1 The order of the selection elements is not significant, and the selection specification can contain white space All element specifications can be comma-separated lists of values. Numerical specifications can also be ranges lower-upper, or delta ranges value+delta, selecting the range from value-delta to value+delta. The element markers have been chosen to minimize clashes with Unix shell special characters. Their mnemonics and meanings are :
For example, to specify the part of the SDIF file piano.sdif which is contained in stream number 1 in 1HRM frames and matrices, and to select only columns 3 and 2 (amplitude and frequency) of rows 1 through 50 (the first fifty partials appearing in each matrix), between the times 1.999 and 2.001, you can say :
piano.sdif :: #1 :1HRM /1HRM .3,2 _1-50 @2+0.001
As a shortcut, if the first selection element is the frame, you can drop the frame
element marker ':'. So, instead of
filename:::frame@cetera it is filename::frame@cetera.
The SDIF selection defines a syntax and a standard semantics for programs reading SDIF files: Specifying a file name plus a selection is exactly equivalent to removing all but the selection from the SDIF file and then specifying that new file (which can be empty). Implementing that semantics is made very easy in the Ircam SDIF library by high level functions: Opening a file automatically parses the selection specification, the SdifFReadNextSelectedFrameHeader 4 and SdifFCurrMatrixIsSelected functions find selected frames and matrices for you, and there are functions which perform the row and column mapping given by the selection.
All Ircam SDIF tools accept an SDIF selection for reading. This works also with standard input, using as filename ::select-spec or -::select-spec.
For writing, the selection can be used to specify the output description type. For example, in Ircam's converter programs from untyped ASCII data to SDIF, you can choose 1HRM or 1TRC output for partial data, or the output type of the ubiquitous two-column break-point function files :
bpftosdif glass.f0 glass.sdif::1FQ0/1FQ0
As these programs also read SDIF, we immediately have an SDIF type converter (use at your own risk).
The selection can also choose the display mode of description types. In the Matlab application ViewEnv [Schwarz, 1998], for instance, the x- and y-axis for frame-wise plotting are given by the column selection. Thus, mongol.sdif::/1HRM,1TRC.2,3 as filename would plot partial amplitude over frequency.
The SDIF selection can also be used for mapping actions to description types, e.g.: ``Edit this frame type with that program''.
This section treats programming language interfaces (APIs) for foreign languages and for C, that allow using the functionality of the SDIF library by applications. The advantages of using the library via one of these interfaces, vs. rewriting the functionality are evident: The programmer profits immediately from all the capabilities of the library, some of which might not be possible at all with a foreign language, and from all future enhancements of the library. Interfaces to other languages, such as Perl or Java, are being considered.® conclusion ?
The SDIF interface for the mathematical modelling and programming language Matlab is realized using its ``mex'' extension interface, based on dynamic link libraries. Its present version allows to read and write SDIF files frame-wise. It is particularly straightforward to use, because the fundamental object of Matlab is the matrix of numbers, which nicely matches the base concept of SDIF. The mex binaries can be downloaded from http://www.ircam.fr/sdif.
For reading, the loadsdif mex-function is called with a filename argument to open an SDIF file, returning header data (1NVT name--value tables). An optional argument can specify a types file with private description type definitions. Subsequent calls read and return one matrix a time, along with the frame time, stream ID, and frame and matrix signatures. An empty matrix signals end-of-file. A further call with the argument 'close' closes the file. This function is aware of the SDIF selection appended to the filename, returning only the selected data.
For writing, the writesdif mex-function opens a file when called with a filename argument. Again, a private types file can be specified. Frames with any number of matrices can be written by one call with the arguments stream ID, frame time, frame signature and one pair matrix signature, matrix data per matrix. A further call with the argument 'close' closes the file 5.
Some support functions have been written in the Matlab programming language itself to further simplify using SDIF :
loads the first partial of any additive analysis data found in file piano.sdif into the matrix m. Its columns are: frame time, partial frequency, partial amplitude. Similarly,m = loadsdifflat('piano.sdif::/1HRM.2,3_1')only one example
loads and plots the fundamental frequency break-point function over time from file f0.sdif.f = loadsdifflat('f0.sdif::1FQ0/1FQ0.1')plot(f(:,1), f(:,2))
The functions of Ircam's SDIF library have been made directly callable from the Lisp dialect CLOS (Common Lisp Object System) on Macintosh by Carlos Agon. This forms the basis of OpenMusic, described in section 4.3. The functions allow reading of frame header and matrix data, searching for data according to the selection, accessing and setting file header data needed by certain Ircam applications 6, and writing frames and matrices.
CLOS allows calling the functions of a dynamic C-library directly. It can also access all scalar C-types, including pointers (it cannot dereference them, though). Because the Ircam SDIF library follows an object-oriented design, all manipulations are carried out on the library's basic objects (SDIF file, frame and matrix headers, selection, list, hash) by calling access functions with the object pointers.
For more efficient usage of the library, and better shielding of the programmer from the details of reading and writing SDIF, a callback-oriented API will be made available as part of the Ircam SDIF library. It supports an alternative programming style for reading and writing by using a ``read/write manager''. Users of the library specify callback functions associated with one SDIF selection each. The library takes care of reading/writing one or more files, and dispatches selected SDIF data to the appropriate callback(s). Writing works analogously: each callback is called in turn to provide data to be written to one or possibly several files by the library. The callbacks can be from independent modules of a system, each handling different parts of SDIF files.
These utilities for Unix and Macintosh are part of the Ircam SDIF library:
Data in file piano-res.sdif (4792 bytes): 1 1REB frames in stream 1 between time 0.0 and\ 0.0 containing 1 1RES matrices with max. 174 rows, 5 columns 1 1CHA matrices with max. 174 rows, 1 columns 4 1NOI frames in stream 2 between time 0.0 and\ 1.3 containing 4 1DIS matrices with max. 1 rows, 2 columns
sdifextract -bpf mongol.sdif::1FQ0.2 | XSedit
Cnmat's SDIF library provides these SDIF utilities :
Ircam's additive sinusoidal analysis--synthesis packages Additive, Partial++, and Hmm all read and write pitch and partial data in SDIF. So does Diphone, which also analyses and synthesizes resonance model and FOF data for Chant in SDIF.
A general SDIF reader/writer has been integrated into jMax [Déchelle, Schnell, Borghesi & Orio, 2000] by Patrice Tisserand. The reader/writer for Max/MSP [Wright, Dudas, Khoury, Wang & Zicarelli, 1999] has been improved: An SDIF-buffer may now hold any number of SDIF streams, and MSP can now look up data in an SDIF stream based on "relative" time, a ratio from zero (the smallest time-tag in the stream) to one (the largest), rather than giving an absolute time in seconds. Cnmat's Open Sound World [Chaudhary, Freed & Wright, 2000] real time synthesis and processing environment also includes support for SDIF.
The Analysis--Synthesis Comparison panel session at
ICMC 2000 has been a major impetus for the adoption of SDIF outside of Ircam
and Cnmat. The idea of the panel is all participants analyse the same set of
input sound files with their various analysis--synthesis software, writing results
as SDIF files. This allows a meaningful and interesting comparison of subtle
and not-so-subtle differences among the different analysis techniques.
Here is the list of participants in the comparison session at the time of writing this paper : Additive [Rodet, 1997], Hmm [Depalle, Garcia & Rodet, 1993], Loris [Fitz, Haken & Chirstensen, 2000], MDSynth [Wakefield, 1998], Partial++, SINOLA [Peeters & Rodet, 1999], SNDAN [Beauchamp, 1993], SMS [Serra, Bonada, Herrera & Loureiro, 1997]. All have committed to supporting SDIF input and output with their analysis--synthesis systems.
OpenMusic [Assayag, Rueda, Laurson, Agon & Delerue, 1999] is an object-oriented visual programming environment for music composers, based on CLOS (section 3.2). Objects are symbolized by icons and operations are performed by dragging an icon from a particular place and dropping it onto another. A multitude of classes implementing musical data and behaviour are provided. They are associated with graphical editors and may be visually subclassed by the user to meet specific needs.
SDIF files and access functions from the Lisp interface (section 3.2) are reified as graphical classes and methods. These allow high-level access to SDIF data (see figure 1), editing, and writing. An application of SDIF in OpenMusic for synthesis is described in [Assayag, Agon & Stroppa, 2000] : generation of control data for the Chant-synthesizer.
Figure 1: Reading from an SDIF file with OpenMusic
Many applications would benefit from rapid random access to data at a given time in an SDIF file, without scanning the whole file. We propose a way to add a frame directory to an SDIF file, which records the file position, type, time, and other information about each data frame occurring in the file.
The SDIF frame directory is best represented as a normal SDIF description type. Thus, programs unaware of this extension can ignore it completely. However, as soon as a program uses a directory-aware SDIF library, the frame directory will be generated and used automatically, e.g. for SDIF selection.
According to our proposition, an SDIF file with a frame directory looks like in figure 2. The directory pointer is the first frame of the file, containing the file position of the directory so that it can be found immediately. The SDIF directory contains the stream IDs, signatures, times, and file positions of all SDIF data frames.
Figure 2 : Schema of an SDIF file with frame directory
An SDIF Directory is represented as a 1DIR SDIF frame. Its time is the time of the last data frame, to preserve the time ordering, as stipulated by the SDIF standard. The SDIF directory consists of directory entries, one for each data frame. The directory pointer is an SDIF directory itself with a single entry, recording the file position of the SDIF directory frame.
To represent the directory entries, we propose a flat representation, which stores the entries as one list of tuples of frame time, signature, stream ID, position. Although introducing redundancy, it offers the most efficient handling and access of the directory. A detailed discussion of the representation can be found on Ircam's SDIF pages at http://www.ircam.fr/sdif.
The list of directory entries is represented in two SDIF Matrices IDIR and 1DIR as shown below, with their data types and column names. One entry is constituted by corresponding rows from the matrices.
IDIR double {time} 1DIR uint32 {frame-type, stream-id, filepos}
File positions are represented by the number of bytes counting from the start of the file, usable with fseek(). 7
The directory pointer is an SDIF directory containing a single entry: the file and time position of the SDIF directory it points to. Even if we don't write the SDIF directory, each file should include a null directory pointer right after the header, which can be used as the standard place to store the size and end time of a file.
Extension of the SDIF directory is possible by adding more information about the frames as additional matrices in the 1DIR frame, or additional columns in the matrices, which are ignored by other programs.
Updating and consistency : When the frame time, type, or stream ID get overwritten, the directory has to be updated or invalidated by setting the directory pointer to null. On re-writing a file, the library would regenerate the SDIF directory. To catch the worst case in which programs change or add some data, and pass the rest through, not being aware of the special meaning of the directory, some sanity checks are performed: First, the target position of the directory pointer can be checked if it actually contains the SDIF directory, if the frame time is correct, and if it is the last frame in the file. Second, every access through the directory can be validated by cross-checking if the frame found at the recorded position is really of the recorded type, time, and stream.
Before our proposal of an SDIF frame directory is standardised, some design decisions have to be made, based on questions like: What is the most frequent access/query on a directory ? It will probably be something like: Where is the frame of stream n with type 1ABC closest to time xyz ?
How often do updates within a file occur versus appends, or do files normally get rewritten when they are edited ? This determines whether to support multiple SDIF directories : The definition could be extended to allow later addition of data to an existing SDIF file, without having to rewrite its frame directory. The SDIF directory would then end with a directory pointer, containing the file position of the next directory for data that has been appended, so that we get a linked list of SDIF directories.
The synergetic effects of the interchange standard SDIF are already visible: OpenMusic generates control data for Chant and jMax, Diphone edits data for jMax and soon will work as a generic SDIF data editor. All applications will immediately benefit from direct access through the SDIF directory. Notably Diphone, OpenMusic, and all applications using the SDIF selection will only have to be relinked with the enhanced Ircam SDIF library. An important extension is the SDIF Stream Relationships Language, discussed in [Wright, Chaudhary, Freed, Khoury, Momeni, Schwarz & Wessel, 2000], a formal language for describing the relationships between streams in an SDIF file, based on XML.
We are working to define an XML-based formal SDIF Type Definition Language for defining description types, to replace Ircam's 1TYP frames. It would define the matrices that must appear in a frame of a given type, define the required and optional columns of a given matrix type, including name, units, and legal ranges, and define the legal matrix data types for each matrix type.
The extensions described here constitute considerable enhancements for SDIF users (utilities and selection), programmers (foreign languages and APIs), and existing and future applications (frame directory), thus accelerating the proliferation of the SDIF format in a multitude of fields and applications.
The authors wish to thank Xavier Rodet, Carlos Agon, Amar Chaudhary, and David Wessel for their support with this article.
This document was translated from LATEX by HEVEA.
____________________________
Server © IRCAM-CGP, 1996-2008 - file updated on .
____________________________
Serveur © IRCAM-CGP, 1996-2008 - document mis à jour le .