TMH / Software

Snack Home Page
The Snack Sound Toolkit
(c) 1997-2004 Kåre Sjölander

    The Snack Sound Toolkit is designed to be used with a scripting language such as Tcl/Tk or Python. Using Snack you can create powerful multi-platform audio applications with just a few lines of code. Snack has commands for basic sound handling, such as playback, recording, file and socket I/O. Snack also provides primitives for sound visualization, e.g. waveforms and spectrograms. It was developed mainly to handle digital recordings of speech, but is just as useful for general audio. Snack has also successfully been applied to other one-dimensional signals.
    The combination of Snack and a scripting language makes it possible to create sound tools and applications with a minimum of effort. This is due to the rapid development nature of scripting languages. As a bonus you get an application that is cross-platform from start. It is also easy to integrate Snack based applications with existing sound analysis software.


    High level sound objects, with flexible storage management and streaming support.

    Multiple simultaneous playback and recording threads (system dependent).

    All audio data handled as floating point internally for fast and accurate computations.

    Multi-platform, same scripts usable on Windows 95/98/NT/2K/XP, Linux, Macintosh, Sun Solaris, HP-UX, FreeBSD, NetBSD, and SGI IRIX.

    Script compilation tool included, for easy deployment using stand-alone executables.

    Filters which can be used to process sound objects or during playback for on-the-fly operation.

    Visualization with waveforms, spectrograms, and spectrum sections. Postscript support.

    Real-time visualization/spectrum analysis.

    Web enabled, possible to run scripts embedded in web pages through the use of the Tcl plug-in.

    Extensible, new commands, filters, and sound file formats can be added using the Snack C-library.

    Lots of examples included as well as a skeleton C-extension.

    Supported sound file formats: WAV, AU, AIFF, MP3, CSL, SD, SMP, and NIST/Sphere


    Snack v2.2.10 released December 01

    WaveSurfer 1.8.5 released November 01
      WaveSurfer is a sound application built using Snack. WaveSurfer was developed mainly for use in speech research, but has also proven useful in many other contexts.

    Snack v2.2.8 part of ActiveState's Tcl/Tk distribution.
      If you need the latest version or the source release download from this site. Otherwise use the ActiveState release.

Download Snack
Installation (with Tcl/Tk)
Installation (with Python)

Introductory examples
Tutorial (Tcl only, there is an introductory section on Snack and Python at the top of the Python manual)

Snack manual for Tcl/Tk, for Python
Writing extensions to Snack in C/C++

Links related to Snack
Links related to scripting languages

Introductory examples

Using Tcl/Tk

The Snack toolkit adds the command snack::sound to the Tcl language. It is used to create and handle sound objects. The following three statements shows how to create a sound object, read audio data from a WAV-file into it and finally play the sound:

snack::sound snd
snd read ex1.wav
snd play

To get a graphical representation of this sound you can draw its waveform using these statements:

canvas .c
pack .c
.c create waveform 0 0 -sound snd

Using Python

The same functions with Snack and Python would be

snd = Sound()'ex1.wav')

And for the graphics

c = SnackCanvas()
c.create_waveform(0, 0, sound=snd)

Last updated January 23, 2006 Department of Speech, Music and Hearing home

Published by: TMH, Speech, Music and Hearing

Last updated: Monday, 23-Jan-2006 17:43:35 MET