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 install libpcre3-dev julia -y
|
||||
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
|
||||
|
|
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
|
||||
development. The API could change, there will be bugs, there are important
|
||||
missing features.
|
||||
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.
|
||||
|
||||
If you want to try it anyways, from your julia console:
|
||||
|
||||
julia> Pkg.clone("https://github.com/ssfrr/PortAudio.jl.git")
|
||||
julia> Pkg.build("PortAudio")
|
||||
julia> Pkg.clone("https://github.com/ssfrr/AudioIO.jl.git")
|
||||
julia> Pkg.build("AudioIO")
|
||||
|
||||
Basic Array Playback
|
||||
--------------------
|
||||
|
|
2
deps/build.jl
vendored
2
deps/build.jl
vendored
|
@ -13,7 +13,7 @@ provides(AptGet,
|
|||
|
||||
@BinDeps.install [:libportaudio => :libportaudio]
|
||||
|
||||
cd(joinpath(Pkg.dir(), "PortAudio", "deps", "src") )
|
||||
cd(joinpath(Pkg.dir(), "AudioIO", "deps", "src") )
|
||||
run(`make`)
|
||||
if (!ispath("../usr"))
|
||||
run(`mkdir ../usr`)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module PortAudio
|
||||
module AudioIO
|
||||
|
||||
# export the basic API
|
||||
export play
|
||||
|
@ -172,15 +172,13 @@ end
|
|||
########### Module Initialization ##############
|
||||
|
||||
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 " *
|
||||
"libportaudio_shim. Try re-running the package script using " *
|
||||
"Pkg.build(\"PortAudio\"), then reloading with reload(\"PortAudio\")")
|
||||
@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\")")
|
||||
|
||||
init_portaudio()
|
||||
|
||||
end # module PortAudio
|
||||
end # module AudioIO
|
||||
|
||||
|
||||
#type PaStreamCallbackTimeInfo
|
|
@ -1,24 +1,24 @@
|
|||
using Base.Test
|
||||
using PortAudio
|
||||
using AudioIO
|
||||
|
||||
const TEST_SAMPLERATE = 44100
|
||||
const TEST_BUF_SIZE = 1024
|
||||
|
||||
type TestAudioStream <: PortAudio.AudioStream
|
||||
type TestAudioStream <: AudioIO.AudioStream
|
||||
mixer::AudioMixer
|
||||
info::PortAudio.DeviceInfo
|
||||
info::AudioIO.DeviceInfo
|
||||
|
||||
function TestAudioStream()
|
||||
mixer = AudioMixer()
|
||||
new(mixer, PortAudio.DeviceInfo(TEST_SAMPLERATE, TEST_BUF_SIZE))
|
||||
new(mixer, AudioIO.DeviceInfo(TEST_SAMPLERATE, TEST_BUF_SIZE))
|
||||
end
|
||||
end
|
||||
|
||||
# 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.
|
||||
function process(stream::TestAudioStream)
|
||||
in_array = zeros(PortAudio.AudioSample, stream.info.buf_size)
|
||||
return PortAudio.render(stream.mixer, in_array, stream.info)
|
||||
in_array = zeros(AudioIO.AudioSample, stream.info.buf_size)
|
||||
return AudioIO.render(stream.mixer, in_array, stream.info)
|
||||
end
|
||||
|
||||
|
||||
|
@ -35,21 +35,21 @@ test_stream = TestAudioStream()
|
|||
player = play(f32, test_stream)
|
||||
@test process(test_stream) == f32[1:TEST_BUF_SIZE]
|
||||
#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...")
|
||||
f64 = convert(Array{Float64}, sin(phase))
|
||||
test_stream = TestAudioStream()
|
||||
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...")
|
||||
i8 = Int8[-127:127]
|
||||
test_stream = TestAudioStream()
|
||||
player = play(i8, test_stream)
|
||||
@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...")
|
||||
# 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()
|
||||
player = play(ui8, test_stream)
|
||||
@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...")
|
||||
|
@ -67,4 +67,4 @@ player = play(ui8, test_stream)
|
|||
#play(node, test_stream)
|
||||
#process(test_stream)
|
||||
#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 PortAudio
|
||||
using AudioIO
|
||||
|
||||
test_info = PortAudio.DeviceInfo(44100, 512)
|
||||
dev_input = zeros(PortAudio.AudioSample, test_info.buf_size)
|
||||
test_info = AudioIO.DeviceInfo(44100, 512)
|
||||
dev_input = zeros(AudioIO.AudioSample, test_info.buf_size)
|
||||
|
||||
# A TestNode just renders out 1:buf_size each frame
|
||||
type TestNode <: PortAudio.AudioNode
|
||||
type TestNode <: AudioIO.AudioNode
|
||||
end
|
||||
|
||||
function PortAudio.render(node::TestNode,
|
||||
device_input::PortAudio.AudioBuf,
|
||||
info::PortAudio.DeviceInfo)
|
||||
return PortAudio.AudioSample[1:info.buf_size]
|
||||
function AudioIO.render(node::TestNode,
|
||||
device_input::AudioIO.AudioBuf,
|
||||
info::AudioIO.DeviceInfo)
|
||||
return AudioIO.AudioSample[1:info.buf_size]
|
||||
end
|
||||
|
||||
#### AudioMixer Tests ####
|
||||
|
@ -21,25 +21,25 @@ end
|
|||
|
||||
info("Testing AudioMixer...")
|
||||
mix = AudioMixer()
|
||||
@test mix.mix_inputs == PortAudio.AudioNode[]
|
||||
@test PortAudio.render(mix, dev_input, test_info) == zeros(PortAudio.AudioSample, test_info.buf_size)
|
||||
@test mix.mix_inputs == AudioIO.AudioNode[]
|
||||
@test AudioIO.render(mix, dev_input, test_info) == zeros(AudioIO.AudioSample, test_info.buf_size)
|
||||
|
||||
testnode = TestNode()
|
||||
mix = AudioMixer([testnode])
|
||||
@test mix.mix_inputs == PortAudio.AudioNode[testnode]
|
||||
@test PortAudio.render(mix, dev_input, test_info) == PortAudio.AudioSample[1:test_info.buf_size]
|
||||
@test mix.mix_inputs == AudioIO.AudioNode[testnode]
|
||||
@test AudioIO.render(mix, dev_input, test_info) == AudioIO.AudioSample[1:test_info.buf_size]
|
||||
|
||||
test1 = TestNode()
|
||||
test2 = TestNode()
|
||||
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...")
|
||||
freq = 440
|
||||
t = linspace(1 / test_info.sample_rate,
|
||||
test_info.buf_size / test_info.sample_rate,
|
||||
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)
|
||||
rendered = PortAudio.render(osc, dev_input, test_info)
|
||||
rendered = AudioIO.render(osc, dev_input, test_info)
|
||||
@test_approx_eq(rendered, test_vect)
|
||||
|
|
Loading…
Reference in a new issue