changes all references of PortAudio name to AudioIO
This commit is contained in:
parent
47046b3d41
commit
97dc8025bf
6 changed files with 42 additions and 42 deletions
|
@ -9,5 +9,5 @@ before_install:
|
||||||
- sudo apt-get update -qq -y
|
- sudo apt-get update -qq -y
|
||||||
- sudo apt-get install libpcre3-dev julia -y
|
- sudo apt-get install libpcre3-dev julia -y
|
||||||
script:
|
script:
|
||||||
- julia -e 'Pkg.init(); run(`ln -s $(pwd()) $(Pkg.dir("PortAudio"))`); Pkg.pin("PortAudio"); Pkg.resolve(); Pkg.add("BinDeps"); Pkg.build("PortAudio")'
|
- julia -e 'Pkg.init(); run(`ln -s $(pwd()) $(Pkg.dir("AudioIO"))`); Pkg.pin("AudioIO"); Pkg.resolve(); Pkg.add("BinDeps"); Pkg.build("AudioIO")'
|
||||||
- test/test.jl
|
- test/test.jl
|
||||||
|
|
18
README.md
18
README.md
|
@ -1,16 +1,18 @@
|
||||||
PortAudio.jl
|
AudioIO.jl
|
||||||
============
|
==========
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/ssfrr/PortAudio.jl.png)](https://travis-ci.org/ssfrr/PortAudio.jl)
|
[![Build Status](https://travis-ci.org/ssfrr/AudioIO.jl.png)](https://travis-ci.org/ssfrr/AudioIO.jl)
|
||||||
|
|
||||||
This is a Julia interface to PortAudio. It is currently under heavy
|
AudioIO is a Julia library for interfacing to audio streams, which include
|
||||||
development. The API could change, there will be bugs, there are important
|
playing to and recording from sound cards, reading and writing audio files,
|
||||||
missing features.
|
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.
|
||||||
|
|
||||||
If you want to try it anyways, from your julia console:
|
If you want to try it anyways, from your julia console:
|
||||||
|
|
||||||
julia> Pkg.clone("https://github.com/ssfrr/PortAudio.jl.git")
|
julia> Pkg.clone("https://github.com/ssfrr/AudioIO.jl.git")
|
||||||
julia> Pkg.build("PortAudio")
|
julia> Pkg.build("AudioIO")
|
||||||
|
|
||||||
Basic Array Playback
|
Basic Array Playback
|
||||||
--------------------
|
--------------------
|
||||||
|
|
2
deps/build.jl
vendored
2
deps/build.jl
vendored
|
@ -13,7 +13,7 @@ provides(AptGet,
|
||||||
|
|
||||||
@BinDeps.install [:libportaudio => :libportaudio]
|
@BinDeps.install [:libportaudio => :libportaudio]
|
||||||
|
|
||||||
cd(joinpath(Pkg.dir(), "PortAudio", "deps", "src") )
|
cd(joinpath(Pkg.dir(), "AudioIO", "deps", "src") )
|
||||||
run(`make`)
|
run(`make`)
|
||||||
if (!ispath("../usr"))
|
if (!ispath("../usr"))
|
||||||
run(`mkdir ../usr`)
|
run(`mkdir ../usr`)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
module PortAudio
|
module AudioIO
|
||||||
|
|
||||||
# export the basic API
|
# export the basic API
|
||||||
export play
|
export play
|
||||||
|
@ -172,15 +172,13 @@ end
|
||||||
########### Module Initialization ##############
|
########### Module Initialization ##############
|
||||||
|
|
||||||
const libportaudio_shim = find_library(["libportaudio_shim",],
|
const libportaudio_shim = find_library(["libportaudio_shim",],
|
||||||
[Pkg.dir("PortAudio", "deps", "usr", "lib"),])
|
[Pkg.dir("AudioIO", "deps", "usr", "lib"),])
|
||||||
|
|
||||||
@assert(libportaudio_shim != "", "Failed to find required library " *
|
@assert(libportaudio_shim != "", "Failed to find required library libportaudio_shim. Try re-running the package script using Pkg.build(\"AudioIO\"), then reloading with reload(\"AudioIO\")")
|
||||||
"libportaudio_shim. Try re-running the package script using " *
|
|
||||||
"Pkg.build(\"PortAudio\"), then reloading with reload(\"PortAudio\")")
|
|
||||||
|
|
||||||
init_portaudio()
|
init_portaudio()
|
||||||
|
|
||||||
end # module PortAudio
|
end # module AudioIO
|
||||||
|
|
||||||
|
|
||||||
#type PaStreamCallbackTimeInfo
|
#type PaStreamCallbackTimeInfo
|
|
@ -1,24 +1,24 @@
|
||||||
using Base.Test
|
using Base.Test
|
||||||
using PortAudio
|
using AudioIO
|
||||||
|
|
||||||
const TEST_SAMPLERATE = 44100
|
const TEST_SAMPLERATE = 44100
|
||||||
const TEST_BUF_SIZE = 1024
|
const TEST_BUF_SIZE = 1024
|
||||||
|
|
||||||
type TestAudioStream <: PortAudio.AudioStream
|
type TestAudioStream <: AudioIO.AudioStream
|
||||||
mixer::AudioMixer
|
mixer::AudioMixer
|
||||||
info::PortAudio.DeviceInfo
|
info::AudioIO.DeviceInfo
|
||||||
|
|
||||||
function TestAudioStream()
|
function TestAudioStream()
|
||||||
mixer = AudioMixer()
|
mixer = AudioMixer()
|
||||||
new(mixer, PortAudio.DeviceInfo(TEST_SAMPLERATE, TEST_BUF_SIZE))
|
new(mixer, AudioIO.DeviceInfo(TEST_SAMPLERATE, TEST_BUF_SIZE))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# render the stream and return the next block of audio. This is used in testing
|
# render the stream and return the next block of audio. This is used in testing
|
||||||
# to simulate the audio callback that's normally called by the device.
|
# to simulate the audio callback that's normally called by the device.
|
||||||
function process(stream::TestAudioStream)
|
function process(stream::TestAudioStream)
|
||||||
in_array = zeros(PortAudio.AudioSample, stream.info.buf_size)
|
in_array = zeros(AudioIO.AudioSample, stream.info.buf_size)
|
||||||
return PortAudio.render(stream.mixer, in_array, stream.info)
|
return AudioIO.render(stream.mixer, in_array, stream.info)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,21 +35,21 @@ test_stream = TestAudioStream()
|
||||||
player = play(f32, test_stream)
|
player = play(f32, test_stream)
|
||||||
@test process(test_stream) == f32[1:TEST_BUF_SIZE]
|
@test process(test_stream) == f32[1:TEST_BUF_SIZE]
|
||||||
#stop(player)
|
#stop(player)
|
||||||
#@test process(test_stream) == zeros(PortAudio.AudioSample, TEST_BUF_SIZE)
|
#@test process(test_stream) == zeros(AudioIO.AudioSample, TEST_BUF_SIZE)
|
||||||
|
|
||||||
|
|
||||||
info("Testing Playing Float64 arrays...")
|
info("Testing Playing Float64 arrays...")
|
||||||
f64 = convert(Array{Float64}, sin(phase))
|
f64 = convert(Array{Float64}, sin(phase))
|
||||||
test_stream = TestAudioStream()
|
test_stream = TestAudioStream()
|
||||||
player = play(f64, test_stream)
|
player = play(f64, test_stream)
|
||||||
@test process(test_stream) == convert(PortAudio.AudioBuf, f64[1:TEST_BUF_SIZE])
|
@test process(test_stream) == convert(AudioIO.AudioBuf, f64[1:TEST_BUF_SIZE])
|
||||||
|
|
||||||
info("Testing Playing Int8(Signed) arrays...")
|
info("Testing Playing Int8(Signed) arrays...")
|
||||||
i8 = Int8[-127:127]
|
i8 = Int8[-127:127]
|
||||||
test_stream = TestAudioStream()
|
test_stream = TestAudioStream()
|
||||||
player = play(i8, test_stream)
|
player = play(i8, test_stream)
|
||||||
@test_approx_eq(process(test_stream)[1:255],
|
@test_approx_eq(process(test_stream)[1:255],
|
||||||
convert(PortAudio.AudioBuf, linspace(-1.0, 1.0, 255)))
|
convert(AudioIO.AudioBuf, linspace(-1.0, 1.0, 255)))
|
||||||
|
|
||||||
info("Testing Playing Uint8(Unsigned) arrays...")
|
info("Testing Playing Uint8(Unsigned) arrays...")
|
||||||
# for unsigned 8-bit audio silence is represented as 128, so the symmetric range
|
# for unsigned 8-bit audio silence is represented as 128, so the symmetric range
|
||||||
|
@ -58,7 +58,7 @@ ui8 = Uint8[1:255]
|
||||||
test_stream = TestAudioStream()
|
test_stream = TestAudioStream()
|
||||||
player = play(ui8, test_stream)
|
player = play(ui8, test_stream)
|
||||||
@test_approx_eq(process(test_stream)[1:255],
|
@test_approx_eq(process(test_stream)[1:255],
|
||||||
convert(PortAudio.AudioBuf, linspace(-1.0, 1.0, 255)))
|
convert(AudioIO.AudioBuf, linspace(-1.0, 1.0, 255)))
|
||||||
|
|
||||||
|
|
||||||
#info("Testing AudioNode Stopping...")
|
#info("Testing AudioNode Stopping...")
|
||||||
|
@ -67,4 +67,4 @@ player = play(ui8, test_stream)
|
||||||
#play(node, test_stream)
|
#play(node, test_stream)
|
||||||
#process(test_stream)
|
#process(test_stream)
|
||||||
#stop(node)
|
#stop(node)
|
||||||
#@test process(test_stream) == zeros(PortAudio.AudioSample, TEST_BUF_SIZE)
|
#@test process(test_stream) == zeros(AudioIO.AudioSample, TEST_BUF_SIZE)
|
|
@ -1,17 +1,17 @@
|
||||||
using Base.Test
|
using Base.Test
|
||||||
using PortAudio
|
using AudioIO
|
||||||
|
|
||||||
test_info = PortAudio.DeviceInfo(44100, 512)
|
test_info = AudioIO.DeviceInfo(44100, 512)
|
||||||
dev_input = zeros(PortAudio.AudioSample, test_info.buf_size)
|
dev_input = zeros(AudioIO.AudioSample, test_info.buf_size)
|
||||||
|
|
||||||
# A TestNode just renders out 1:buf_size each frame
|
# A TestNode just renders out 1:buf_size each frame
|
||||||
type TestNode <: PortAudio.AudioNode
|
type TestNode <: AudioIO.AudioNode
|
||||||
end
|
end
|
||||||
|
|
||||||
function PortAudio.render(node::TestNode,
|
function AudioIO.render(node::TestNode,
|
||||||
device_input::PortAudio.AudioBuf,
|
device_input::AudioIO.AudioBuf,
|
||||||
info::PortAudio.DeviceInfo)
|
info::AudioIO.DeviceInfo)
|
||||||
return PortAudio.AudioSample[1:info.buf_size]
|
return AudioIO.AudioSample[1:info.buf_size]
|
||||||
end
|
end
|
||||||
|
|
||||||
#### AudioMixer Tests ####
|
#### AudioMixer Tests ####
|
||||||
|
@ -21,25 +21,25 @@ end
|
||||||
|
|
||||||
info("Testing AudioMixer...")
|
info("Testing AudioMixer...")
|
||||||
mix = AudioMixer()
|
mix = AudioMixer()
|
||||||
@test mix.mix_inputs == PortAudio.AudioNode[]
|
@test mix.mix_inputs == AudioIO.AudioNode[]
|
||||||
@test PortAudio.render(mix, dev_input, test_info) == zeros(PortAudio.AudioSample, test_info.buf_size)
|
@test AudioIO.render(mix, dev_input, test_info) == zeros(AudioIO.AudioSample, test_info.buf_size)
|
||||||
|
|
||||||
testnode = TestNode()
|
testnode = TestNode()
|
||||||
mix = AudioMixer([testnode])
|
mix = AudioMixer([testnode])
|
||||||
@test mix.mix_inputs == PortAudio.AudioNode[testnode]
|
@test mix.mix_inputs == AudioIO.AudioNode[testnode]
|
||||||
@test PortAudio.render(mix, dev_input, test_info) == PortAudio.AudioSample[1:test_info.buf_size]
|
@test AudioIO.render(mix, dev_input, test_info) == AudioIO.AudioSample[1:test_info.buf_size]
|
||||||
|
|
||||||
test1 = TestNode()
|
test1 = TestNode()
|
||||||
test2 = TestNode()
|
test2 = TestNode()
|
||||||
mix = AudioMixer([test1, test2])
|
mix = AudioMixer([test1, test2])
|
||||||
@test PortAudio.render(mix, dev_input, test_info) == 2 * PortAudio.AudioSample[1:test_info.buf_size]
|
@test AudioIO.render(mix, dev_input, test_info) == 2 * AudioIO.AudioSample[1:test_info.buf_size]
|
||||||
|
|
||||||
info("Testing SinOSC...")
|
info("Testing SinOSC...")
|
||||||
freq = 440
|
freq = 440
|
||||||
t = linspace(1 / test_info.sample_rate,
|
t = linspace(1 / test_info.sample_rate,
|
||||||
test_info.buf_size / test_info.sample_rate,
|
test_info.buf_size / test_info.sample_rate,
|
||||||
test_info.buf_size)
|
test_info.buf_size)
|
||||||
test_vect = convert(PortAudio.AudioBuf, sin(2pi * t * freq))
|
test_vect = convert(AudioIO.AudioBuf, sin(2pi * t * freq))
|
||||||
osc = SinOsc(freq)
|
osc = SinOsc(freq)
|
||||||
rendered = PortAudio.render(osc, dev_input, test_info)
|
rendered = AudioIO.render(osc, dev_input, test_info)
|
||||||
@test_approx_eq(rendered, test_vect)
|
@test_approx_eq(rendered, test_vect)
|
||||||
|
|
Loading…
Reference in a new issue