WFDB SWIG Wrappers

The new PhysioNet website is available at: We welcome your feedback.

Notice: This release of the wfdb-swig package is compatible with version 10.5.0 and later versions of the WFDB Software Package. The most recent version of the WFDB Software Package should be installed on your system in order to make successful use of the wfdb-swig package.

The following combinations of target languages and platforms are known to work using the standard build procedure:

GNU/LinuxMac OS XMS Windows
Perl 5worksworks

Other combinations may also work with minor changes in the build procedure. If you can document the steps needed to build any of the combinations not marked in the table above, please send details.


Wrappers are fragments of "glue code" that allow functions or subroutines written in one language to be invoked by code written in another ("target") language.

The WFDB library is a collection of specialized functions that provide uniform access to digitized signals and annotations in a wide variety of formats, including those in PhysioBank. The WFDB library is written in C and includes bindings for C++ and wrappers for Fortran.

The wfdb-swig package provides wrappers that permit programs written in several other programming languages to use the WFDB library. The wrappers are generated automatically using the Simplified Wrapper Interface Generator (SWIG). Tested target languages include Perl5, Python, Java, and .NET languages (C# and Visual Basic). It may also be possible to generate wrappers for other languages supported by SWIG, including Guile, mzScheme, Octave, PHP, Ruby, and Tcl.


The WFDB Toolkit for Matlab uses the Java wrappers from this package to provide efficient access to WFDB applications such as rdann, rdsamp, wrann, and wrsamp from the Matlab environment. One-click installation is possible; it is not necessary to have installed the wfdb-swig package beforehand.

Raja Selvaraj is developing a pure Python module without external dependencies that provides a subset of rdann and rdsamp functionality. The current version can read local records (no NETFILES) containing exactly two signals stored in format 212. Download the code ( and its documentation (links will open in another window).


Isaac Henry (, George Moody (

Background literature:

The SWIG web site (
The WFDB Programmer's Guide


GNU/Linux (development) Mac OS X, MS Windows. Other platforms supported by SWIG should also work but have not been tested.

Code organization:

The SWIG interface file wfdb.i defines the WFDB API and provides the information needed by SWIG to create the wrappers. The generated wrapper code for each language is stored in a subdirectory (wfdb-java, wfdb-perl, etc.) together with other files needed for that language. See the README files in the language-specific subdirectories for details.


The current version of the wfdb-swig package (most recently updated on Wednesday, 13 July 2011 at 00:17 CEST) may be downloaded in source form, as a tarball (wfdb-swig.tar.gz, 138K). (If you are unfamiliar with tarballs, please read about how to unpack them in the FAQ.) You may also browse through the source tree to read or download individual files.

Older versions of the wfdb-swig package are also available in the PhysioToolkit Archives.


See INSTALL in the top-level wfdb-swig directory.


The C programming examples from the WFDB Programmer's Guide have been translated to each tested language and are located in the examples subdirectory. To test the wrappers after installing them, use 'make check' as described in INSTALL, or test them more extensively by comparing the outputs of these examples against those of the original C examples, which are included in the examples directory of the WFDB Software Package.

Further work:

Updating/modifying the wrappers

The wrappers will need to be regenerated for new versions of WFDB if the WFDB API changes in any way that is not backward-compatible, such as by removal or redefinition of public functions, constants, macros, or data types. Such changes are signalled by a new major or minor WFDB version number (for example, the wrappers need to be regenerated when upgrading from WFDB 10.4.x to 10.5). Versions that differ by release number only (e.g., 10.5.0 and 10.5.8) share the same API and can use the same set of wrappers.

Note that new functions are occasionally added without a change in the major or minor versions of the WFDB library. In such cases, the wrappers can be regenerated to obtain access to the new functions; using an old copy of the WFDB library with regenerated wrappers can result in run-time errors if newly-defined functions are missing.

When using the normal installation procedure (see INSTALL), the wrappers are regenerated automatically by SWIG as needed, based on the contents of the SWIG interface file wfdb.i. Language-specific interface files may also be located in each subdirectory (e.g. wfdb-java/javadoc.i). Source files (*.c, *.java, *.cs, *.py, and so on) are auto-generated by SWIG and should not be edited manually under any circumstances.

Since wfdb.i includes wfdb.h (the C-language WFDB library API), new or modified functions, constants, and data types that may appear in new versions of the WFDB library are picked up automatically, and no changes to the SWIG interface files are required. Macros, however, are not automatically wrapped by SWIG; if necessary, they can be implemented as C functions in wfdb.i, as was done in Isaac Henry's original version of these wrappers for use with WFDB library version 10.3. Beginning with WFDB library version 10.4, automatically wrappable function equivalents are provided for all public macros, so it should no longer be necessary to modify wfdb.i for this purpose.

Creating wrappers for other target languages

This package currently contains wrappers for Perl, Python, Java, and .NET. Follow these examples to generate wrappers for other languages supported by SWIG; if you are successful, please write to to let us know what you did and how you did it.

Language-specific documentation

At present SWIG does not support generation of language specific documentation (such as javadoc). Future versions of SWIG may add this functionality.

Questions and Comments

If you would like help understanding, using, or downloading content, please see our Frequently Asked Questions.

If you have any comments, feedback, or particular questions regarding this page, please send them to the webmaster.

Comments and issues can also be raised on PhysioNet's GitHub page.

Updated Thursday, 09-Jul-2015 16:41:03 CEST

PhysioNet is supported by the National Institute of General Medical Sciences (NIGMS) and the National Institute of Biomedical Imaging and Bioengineering (NIBIB) under NIH grant number 2R01GM104987-09.