2014-01-03 16:41:00 +01:00
|
|
|
AudioIO.jl
|
|
|
|
==========
|
2013-12-13 08:48:52 +01:00
|
|
|
|
2014-01-03 16:41:00 +01:00
|
|
|
[![Build Status](https://travis-ci.org/ssfrr/AudioIO.jl.png)](https://travis-ci.org/ssfrr/AudioIO.jl)
|
2013-12-14 06:20:01 +01:00
|
|
|
|
2014-01-03 16:41:00 +01:00
|
|
|
AudioIO is a Julia library for interfacing to audio streams, which include
|
|
|
|
playing to and recording from sound cards, reading and writing audio files,
|
|
|
|
sending to network audio streams, etc. Currently only playing to the sound card
|
|
|
|
through PortAudio is supported. It is under heavy development, so the API could
|
|
|
|
change, there will be bugs, there are important missing features.
|
2013-12-13 08:48:52 +01:00
|
|
|
|
|
|
|
If you want to try it anyways, from your julia console:
|
|
|
|
|
2014-01-03 16:41:00 +01:00
|
|
|
julia> Pkg.clone("https://github.com/ssfrr/AudioIO.jl.git")
|
|
|
|
julia> Pkg.build("AudioIO")
|
2013-12-13 08:48:52 +01:00
|
|
|
|
2013-12-30 12:29:43 +01:00
|
|
|
Basic Array Playback
|
|
|
|
--------------------
|
2013-12-13 08:48:52 +01:00
|
|
|
|
2013-12-30 12:29:43 +01:00
|
|
|
Arrays in various formats can be played through your soundcard. Currently the
|
2013-12-30 12:33:00 +01:00
|
|
|
native format that is delivered to the PortAudio backend is Float32 in the
|
|
|
|
range of [-1, 1]. Arrays in other sizes of float are converted. Arrays
|
2013-12-30 12:29:43 +01:00
|
|
|
in Signed or Unsigned Integer types are scaled so that the full range is
|
2013-12-30 12:33:00 +01:00
|
|
|
mapped to [-1, 1] floating point values.
|
2013-12-30 12:29:43 +01:00
|
|
|
|
|
|
|
To play a 1-second burst of noise:
|
|
|
|
|
|
|
|
julia> v = rand(44100) * 0.1
|
|
|
|
julia> play(v)
|
|
|
|
|
|
|
|
AudioNodes
|
|
|
|
----------
|
|
|
|
|
|
|
|
In addition to the basic `play` function you can create more complex networks
|
2013-12-30 12:33:00 +01:00
|
|
|
of AudioNodes in a render chain. In fact, when using the basic `play` to play
|
|
|
|
an Array, behind the scenes an instance of the ArrayPlayer type is created
|
|
|
|
and added to the master AudioMixer inputs.
|
2013-12-30 12:29:43 +01:00
|
|
|
|
|
|
|
To explictly do the same as above:
|
|
|
|
|
|
|
|
julia> v = rand(44100) * 0.1
|
|
|
|
julia> player = ArrayPlayer(v)
|
|
|
|
julia> play(player)
|
|
|
|
|
|
|
|
To generate 2 sin tones:
|
|
|
|
|
|
|
|
julia> osc1 = SinOsc(440)
|
|
|
|
julia> osc2 = SinOsc(660)
|
|
|
|
julia> play(osc1)
|
|
|
|
julia> play(osc2)
|
|
|
|
|
|
|
|
All AudioNodes should implement a `render` function that can be called to
|
|
|
|
retreive the next block of audio.
|
|
|
|
|
|
|
|
AudioStreams
|
|
|
|
------------
|
|
|
|
|
|
|
|
AudioStreams represent a destination for audio, such as the sound card. The
|
|
|
|
`play` function attaches AudioNodes to the default stream unless a stream is
|
|
|
|
given as the 2nd argument.
|
|
|
|
|
|
|
|
AudioStream is an abstract type, which currently has a PortAudioStream subtype
|
|
|
|
that writes to the sound card, and a TestAudioStream that is used in the unit
|
|
|
|
tests.
|
|
|
|
|
|
|
|
Currently only 1 stream at a time is supported so there's no reason to provide
|
|
|
|
an explicit stream to the `play` function. The stream has a root mixer field
|
2013-12-30 12:33:00 +01:00
|
|
|
which is an instance of the AudioMixer type, so that multiple AudioNodes
|
2013-12-30 12:29:43 +01:00
|
|
|
can be heard at the same time. Whenever a new frame of audio is needed by the
|
|
|
|
sound card, the stream calls the `render` method on the root audio mixer, which
|
2013-12-30 12:33:00 +01:00
|
|
|
will in turn call the `render` methods on any input AudioNodes that are set
|
2013-12-30 12:29:43 +01:00
|
|
|
up as inputs.
|