Code Monkey home page Code Monkey logo

audioio.jl's People

Contributors

bauglir avatar calder avatar goretkin avatar ssfrr avatar staticfloat avatar zhemao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

audioio.jl's Issues

[PkgEval] AudioIO may have a testing issue on Julia 0.3 (2014-10-17)

PackageEvaluator.jl is a script that runs nightly. It attempts to load all Julia packages and run their tests (if available) on both the stable version of Julia (0.3) and the nightly build of the unstable version (0.4). The results of this script are used to generate a package listing enhanced with testing results.

On Julia 0.3

  • On 2014-10-16 the testing status was Tests pass.
  • On 2014-10-17 the testing status changed to Tests fail, but package loads.

Tests pass. means that PackageEvaluator found the tests for your package, executed them, and they all passed.

Tests fail, but package loads. means that PackageEvaluator found the tests for your package, executed them, and they didn't pass. However, trying to load your package with using worked.

This issue was filed because your testing status became worse. No additional issues will be filed if your package remains in this state, and no issue will be filed if it improves. If you'd like to opt-out of these status-change messages, reply to this message saying you'd like to and @IainNZ will add an exception. If you'd like to discuss PackageEvaluator.jl please file an issue at the repository. For example, your package may be untestable on the test machine due to a dependency - an exception can be added.

Test log:

>>> 'Pkg.add("AudioIO")' log
INFO: Cloning cache of AudioIO from git://github.com/ssfrr/AudioIO.jl.git
INFO: Cloning cache of BinDeps from git://github.com/JuliaLang/BinDeps.jl.git
INFO: Cloning cache of SHA from git://github.com/staticfloat/SHA.jl.git
INFO: Cloning cache of URIParser from git://github.com/JuliaWeb/URIParser.jl.git
INFO: Installing AudioIO v0.1.1
INFO: Installing BinDeps v0.3.6
INFO: Installing SHA v0.0.3
INFO: Installing URIParser v0.0.3
INFO: Building AudioIO
INFO: Package database updated

>>> 'using AudioIO' log
Julia Version 0.3.1
Commit c03f413* (2014-09-21 21:30 UTC)
Platform Info:
  System: Linux (x86_64-unknown-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

>>> test log
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
... truncated ...
process_events at ./stream.jl:537
wait at ./task.jl:273
wait at ./task.jl:194
jl_apply_generic at /home/idunning/julia03/usr/bin/../lib/libjulia.so (unknown line)
stream_wait at ./stream.jl:263
wait at ./process.jl:619
success at process.jl:492
jlcall_success;19829 at  (unknown line)
jl_apply_generic at /home/idunning/julia03/usr/bin/../lib/libjulia.so (unknown line)
run at ./process.jl:479
jl_apply_generic at /home/idunning/julia03/usr/bin/../lib/libjulia.so (unknown line)
anonymous at pkg/entry.jl:692
cd at ./file.jl:20
jl_apply_generic at /home/idunning/julia03/usr/bin/../lib/libjulia.so (unknown line)
test! at pkg/entry.jl:685
jlcall___test!#238__;19675 at  (unknown line)
jl_apply_generic at /home/idunning/julia03/usr/bin/../lib/libjulia.so (unknown line)
julia_test!;19674 at  (unknown line)
test at pkg/entry.jl:709
jlcall___test#239__;19672 at  (unknown line)
jl_apply_generic at /home/idunning/julia03/usr/bin/../lib/libjulia.so (unknown line)
julia_test;19671 at  (unknown line)
jlcall_test;19671 at  (unknown line)
jl_f_apply at /home/idunning/julia03/usr/bin/../lib/libjulia.so (unknown line)
anonymous at pkg/dir.jl:28
cd at ./file.jl:20
jl_apply_generic at /home/idunning/julia03/usr/bin/../lib/libjulia.so (unknown line)
cd at pkg/dir.jl:28
jl_apply_generic at /home/idunning/julia03/usr/bin/../lib/libjulia.so (unknown line)
jl_f_apply at /home/idunning/julia03/usr/bin/../lib/libjulia.so (unknown line)
julia_cd;19663 at  (unknown line)
test at pkg.jl:67
jl_apply_generic at /home/idunning/julia03/usr/bin/../lib/libjulia.so (unknown line)
jl_f_apply at /home/idunning/julia03/usr/bin/../lib/libjulia.so (unknown line)
julia_test;19660 at  (unknown line)
jl_apply_generic at /home/idunning/julia03/usr/bin/../lib/libjulia.so (unknown line)
unknown function (ip: -412430072)
unknown function (ip: -412433799)
unknown function (ip: -412367298)
jl_f_top_eval at /home/idunning/julia03/usr/bin/../lib/libjulia.so (unknown line)
process_options at ./client.jl:213
_start at ./client.jl:354
_start_3B_1712 at /home/idunning/julia03/usr/bin/../lib/julia/sys.so (unknown line)
jl_apply_generic at /home/idunning/julia03/usr/bin/../lib/libjulia.so (unknown line)
unknown function (ip: 4200466)
julia_trampoline at /home/idunning/julia03/usr/bin/../lib/libjulia.so (unknown line)
unknown function (ip: 4199453)
__libc_start_main at /usr/lib/libc.so.6 (unknown line)
unknown function (ip: 4199507)
unknown function (ip: 0)

>>> end of log

Support multichannel audio

Currently we're sending a mono signal out to PortAudio. We need to put some thought into how multichannel audio should be handled.

I think in general the audio should be passed around in NxM vectors, where N is the # of frames and M is the number of channels.

This is related to AudioNodes that might have multiple inputs and/or outputs. For instance, a Panner node would have 1 input and 2 outputs. Should it be a stereo output, or 2 separate outputs? The AudioMixer node has potentially many inputs, but they're likely from different nodes so I'd think of them as separate inputs, not a single multichannel input. Can AudioMixer mix multiple stereo inputs into a single stereo output?

needs more thought.

Can't install on Arch Linux

Carrying this over from julia-dev, basically because of the lack of apt-get on Arch this doesn't install, and so PackageEvaluator doesn't like it.

I'm going to add an "exception" for this package due to this - unless you are planning on providing a build-from-source option

Real Time audio recording examples missing

Excuse me, I am working about Digital Signal Processing specifically Modulation and I want to record my voice in real time but I don't know how do that. I tried to look for something in "AudioIO.jl" about my problem but nothing. Could you make some examples about how record audio in real time please ?

PD: My OS: Windows 8 and a VM: Ubuntu 14.0.4

Incorporate control signals

(from an email conversation with Shashi Gowda)
At some point we need to allow users to vary AudioNode parameters on the fly. Reactive.jl might be a good conceptual framework and library to handle this. It also might be worth checking out The Haskell School of Music

s = SinOsc(440)
play(s)
wait(1)
stop(s)

And you'll hear 1 second of 440hz sin tone. Rather than putting a constant value for the frequency you can put another AudioNode instance, e.g.

f = LinRamp(220, 440, 1)
s = SinOsc(f)
play(s)

And you'll hear a Sin tone sweeping from 220hz to 440hz.

With a little knowledge of AudioIO internals you can change the frequency on the fly:

julia> s = SinOsc(220)
julia> play(s)
# oscillator plays at 220hz
julia> s.renderer.freq = 330
# oscillator plays at 330hz

So currently they support providing a Real value or and AudioNode, it would fit well into the design to accept a Signal as well, so that as the value changes it would automatically propagate where it needs to go.

The play()-function is broken

After updating julia and the AudioIO-package the play()-function stopped working correctly.
If I do a

using AudioIO
play(SinOsc(440))

I only hear the first ~100ms of the sound. When calling play() again nothing is played even though
i don't receive an error message.
If I load a stream manually

stre=AudioIO.Pa_openDefaultStream(0,2,convert(AudioIO.PaSampleFormat,0x01),48000,1024)
Audio().Pa_StartStream(stre)
AudioIO.Pa_WriteStream(stre,convert(Array{Float32},sin(2*pi*220*[1:1024]/48000)))

I get the same effect. The first write gives me a short beep subsequent writes are mute.
My julia version is

julia> versioninfo()
Julia Version 0.4.0-dev+1701
Commit 6a3763e* (2014-11-20 09:16 UTC)
Platform Info:
  System: Linux (x86_64-unknown-linux-gnu)
  CPU: Intel(R) Core(TM) i5-2467M CPU @ 1.60GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

My portaudio version is

PortAudio V19-devel (built Jan 31 2014 21:19:35)%

and my alsa version is

Advanced Linux Sound Architecture Driver Version k3.17.3-1-ARCH.

I would be thankful for any pointers, ideas...

P.S.: Calling portaudio from a C program works fine.

Info about upcoming removal of packages in the General registry

As described in https://discourse.julialang.org/t/ann-plans-for-removing-packages-that-do-not-yet-support-1-0-from-the-general-registry/ we are planning on removing packages that do not support 1.0 from the General registry. This package has been detected to not support 1.0 and is thus slated to be removed. The removal of packages from the registry will happen approximately a month after this issue is open.

To transition to the new Pkg system using Project.toml, see https://github.com/JuliaRegistries/Registrator.jl#transitioning-from-require-to-projecttoml.
To then tag a new version of the package, see https://github.com/JuliaRegistries/Registrator.jl#via-the-github-app.

If you believe this package has erroneously been detected as not supporting 1.0 or have any other questions, don't hesitate to discuss it here or in the thread linked at the top of this post.

PaStream as Ptr{Void} loses information about the data stream

It's difficult in practice to convert PaStream data easily to its actual number data when it is returned as a fully opaque type Rtr{Void}. Since all portaudio stream types are multiples of 8 bits in their number sizes (8, 16, 24, or 32 bits actually) the type of PaStream might be better as something like Ptr{UInt8}. That might allow a safe call to reinterpret() to get the actual data numbers.

Audio feedback when Julia is busy

Currently the audio task shares the same memory space for input and output. That means that if Julia is busy (for instance the JIT is compiling something) and so the callback isn't running, the input just gets fed back to the output, so you hear an echo and feedback.

So far this is confirmed on OSX, not sure if it happens on Linux as well. It probably depends on what the underlying audio system does when the audio deadline is missed.

Make Error in Fedora 23

Running Pkg.add("AudioIO") on Fedora 23 yields a make error. To remedy this you can run the command:

    sudo dnf install portaudio

Then launch Julia and reinstall / remake AudioIO

Segfault on play

julia> using AudioIO

julia> play([sin(440x) for x=1:440])
INFO: Initializing PortAudio. Expect errors as we scan devices
INFO: Launching PortAudio Task...
INFO: Audio Task Launched
INFO: Audio Task Yielded, starting the stream...
INFO: Portaudio stream started.
Process 93552 stopped
* thread #7: tid = 0x2f283d, 0x00000001011f9ec4 libportaudio_shim.dylib`paCallback(inputBuffer=0x0000000000000000, outputBuffer=0x0000000102057a00, framesPerBuffer=1024, timeInfo=0x000000010bfe36f0, statusFlags=0, userData=0x0000000000000000) + 84 at shim.c:105, name = 'com.apple.audio.IOThread.client', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00000001011f9ec4 libportaudio_shim.dylib`paCallback(inputBuffer=0x0000000000000000, outputBuffer=0x0000000102057a00, framesPerBuffer=1024, timeInfo=0x000000010bfe36f0, statusFlags=0, userData=0x0000000000000000) + 84 at shim.c:105
   102      return 0;
   103  }
(lldb) bt
* thread #7: tid = 0x2f283d, 0x00000001011f9ec4 libportaudio_shim.dylib`paCallback(inputBuffer=0x0000000000000000, outputBuffer=0x0000000102057a00, framesPerBuffer=1024, timeInfo=0x000000010bfe36f0, statusFlags=0, userData=0x0000000000000000) + 84 at shim.c:105, name = 'com.apple.audio.IOThread.client', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x00000001011f9ec4 libportaudio_shim.dylib`paCallback(inputBuffer=0x0000000000000000, outputBuffer=0x0000000102057a00, framesPerBuffer=1024, timeInfo=0x000000010bfe36f0, statusFlags=0, userData=0x0000000000000000) + 84 at shim.c:105
    frame #1: 0x000000010b8f062a libportaudio.2.dylib`AdaptingOutputOnlyProcess + 215
    frame #2: 0x000000010b8ef935 libportaudio.2.dylib`PaUtil_EndBufferProcessing + 608
    frame #3: 0x000000010b8f4f23 libportaudio.2.dylib`AudioIOProc + 1786
    frame #4: 0x000000010e809039 CoreAudio`AUInputElement::PullInput(unsigned int&, AudioTimeStamp const&, unsigned int, unsigned int) + 177
    frame #5: 0x000000010e8088ef CoreAudio`AUInputFormatConverter2::InputProc(OpaqueAudioConverter*, unsigned int*, AudioBufferList*, AudioStreamPacketDescription**, void*) + 193
    frame #6: 0x00007fff8d65c185 AudioToolbox`AudioConverterChain::CallInputProc(unsigned int) + 417
    frame #7: 0x00007fff8d65bed1 AudioToolbox`AudioConverterChain::FillBufferFromInputProc(unsigned int*, CABufferList*) + 125
    frame #8: 0x00007fff8d63af19 AudioToolbox`BufferedAudioConverter::GetInputBytes(unsigned int, unsigned int&, CABufferList const*&) + 179
    frame #9: 0x00007fff8d619c9a AudioToolbox`CBRConverter::RenderOutput(CABufferList*, unsigned int, unsigned int&, AudioStreamPacketDescription*) + 104
    frame #10: 0x00007fff8d63ada0 AudioToolbox`BufferedAudioConverter::FillBuffer(unsigned int&, AudioBufferList&, AudioStreamPacketDescription*) + 286
    frame #11: 0x00007fff8d65bce9 AudioToolbox`AudioConverterChain::RenderOutput(CABufferList*, unsigned int, unsigned int&, AudioStreamPacketDescription*) + 99
    frame #12: 0x00007fff8d63ada0 AudioToolbox`BufferedAudioConverter::FillBuffer(unsigned int&, AudioBufferList&, AudioStreamPacketDescription*) + 286
    frame #13: 0x00007fff8d6194ee AudioToolbox`AudioConverterFillComplexBuffer + 292
    frame #14: 0x000000010e8087a6 CoreAudio`AUInputFormatConverter2::PullAndConvertInput(AudioTimeStamp const&, unsigned int&, AudioBufferList&, AudioStreamPacketDescription*, bool&) + 98
    frame #15: 0x000000010e80808a CoreAudio`AUConverterBase::RenderBus(unsigned int&, AudioTimeStamp const&, unsigned int, unsigned int) + 188
    frame #16: 0x000000010e805c61 CoreAudio`AUBase::DoRenderBus(unsigned int&, AudioTimeStamp const&, unsigned int, AUOutputElement*, unsigned int, AudioBufferList&) + 153
    frame #17: 0x000000010e804515 CoreAudio`AUBase::DoRender(unsigned int&, AudioTimeStamp const&, unsigned int, unsigned int, AudioBufferList&) + 423
    frame #18: 0x000000010e80b878 CoreAudio`AUHAL::AUIOProc(unsigned int, AudioTimeStamp const*, AudioBufferList const*, AudioTimeStamp const*, AudioBufferList*, AudioTimeStamp const*, void*) + 2076
    frame #19: 0x00007fff8ac2bacb CoreAudio`HALC_ProxyIOContext::IOWorkLoop() + 3667
    frame #20: 0x00007fff8ac2abcd CoreAudio`HALC_ProxyIOContext::IOThreadEntry(void*) + 97
    frame #21: 0x00007fff8ac2aa8d CoreAudio`HALB_IOThread::Entry(void*) + 75
    frame #22: 0x00007fff89244899 libsystem_pthread.dylib`_pthread_body + 138
    frame #23: 0x00007fff8924472a libsystem_pthread.dylib`_pthread_start + 137

Windows Support

Pretty much the only thing that should need to be fixed to work in windows is the synchronization between the Julia task and the C PortAudio callback. Currently we're using a POSIX semaphore and a file descriptor. I'm not sure what the best windows equivalents are.

-s

AudioIO uses deprecated Dict syntax

using AudioIO

WARNING: deprecated syntax "{a=>b, ...}" at /home/fl/.julia/v0.4/AudioIO/src/portaudio.jl:40.
Use "Dict{Any,Any}(a=>b, ...)" instead.

WARNING: deprecated syntax "[a=>b, ...]" at /home/fl/.julia/v0.4/AudioIO/src/sndfile.jl:20.
Use "Dict(a=>b, ...)" instead.

We should use Compat.jl for cross-version compatibility.

Support auto samplerate conversion

When a sound file (or other object with a fixed samplerate) is played on a stream of a different samplerate, AudioIO should do on-the-fly samplerate conversion.

ArrayPlayer should wait for data to be loaded before starting timer

If you play a long array, the first part of the waveform is not played. It seems that the internal timer starts immediately when play is called but audio doesn't begin playback until the entire waveform is sent to ArrayPlayer. When the playback begins, it jumps to the current time rather than starting from zero, with the effect that the time spent waiting for ArrayPlayer to initialize is skipped over in playback.

AudioIO is almost totally undocumented

Currently there's just the README with basic usage examples. There should be per-function documentation, as well as documentation for each AudioNode type.

“ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred” - Error in julia while trying to play audio

Can someone tell what is this error when trying to play audio in JULIA ? How to solve this? I am using the library AudioIO. And trying to play a sinusoid.

julia> x=sin(0:.01:2_pi_500*5);

julia> using AudioIO

julia> play(x)
INFO: Initializing PortAudio. Expect errors as we scan devices
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
ALSA lib pcm_dmix.c:961:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
INFO: Launching PortAudio Task...
INFO: Audio Task Launched
INFO: Audio Task Yielded, starting the stream...
INFO: Portaudio stream started.
ArrayPlayer(true,[0.0f0,0.009999833f0,0.019998666f0,0.029995501f0,0.039989334f0,0.04997917f0,0.059964005f0,0.06994285f0,0.0799147f0,0.08987855f0 … -0.09313279f0,-0.083171755f0,-0.07320242f0,-0.063225746f0,-0.05324276f0,-0.04325445f0,-0.033261813f0,-0.02326585f0,-0.01326756f0,-0.0032679432f0],1)

julia> ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred

error compiling open_portaudio_stream on OSX

On Julia 0.3-rc1 I'm seeing

ERROR: error compiling play: error compiling play: error compiling open_portaudio_stream: could not load module : dlopen(.dylib, 1): image not found

when I try to play(v).

The building of AudioIO seemed to have gone fine. I'm wondering why it can't seem to find the portaudio dylib?

I checked that libportaudio was indeed installed here ".julia/v0.3/Homebrew/deps/usr/lib/libportaudio.dy"

P.S. I don't have Homebrew installed my machine, so Julia only is using the interval version. Could that be an issue?

not working in Julia version 0.5.0-rc3+0

Following error when trying to install on version 0.5:

INFO: Building AudioIO
===================================================[ ERROR: AudioIO ]===================================================

LoadError: syntax: { } vector syntax is discontinued
while loading /Users/ianmarshall/.julia/v0.5/AudioIO/deps/build.jl, in expression starting on line 11

========================================================================================================================

====================================================[ BUILD ERRORS ]====================================================

WARNING: AudioIO had build errors.

 - packages with build errors remain installed in /Users/ianmarshall/.julia/v0.5
 - build the package(s) and all dependencies with `Pkg.build("AudioIO")`
 - build a single package by running its `deps/build.jl` script

========================================================================================================================

Support waiting for audio playback to finish

Currently it isn't really possible to play audio from a Julia script because the play function is non-blocking. The process will exit before the audio finishes playing. We should provide some facility that would allow the main task to block until all of the audio tasks have finished. The best way to do this would probably be to implement a new method for the Base.wait function.

Proof of concept DSP node

I have a proof of concept (DSP) filtering node. For some reason, in this example, it only works when played before playing another node. I'm sure I'm doing something wrong.

Anyways, this isn't a real issue. Just wanted to share. And thanks for writing such easy to extend code. I've used AudioIO, but never looked at the internals before this evening. I basically just cut and pasted your Gain node and got the Filter node working in a couple hours without having any idea what I was doing.

If you want to try it out, I must warn you that firdes might be broken, and may not be setting the correct cutoff frequency. But at least in the example it appears to be cutting off the 8 kHz tone.

Thanks!

Close audio stream when nothing is playing

Copied from @flpf's comment in #29:

I was wondering if it would be possible to include something like Octaves 'sound()' or 'soundsc()'function in AudioiO. I just wrote a small script using AudioIO-functions to illustrate the idea. It seems to work without error messages.
I had some time to look through the code of the package and I think that I understood
your idea a little bit better. For the node-concept a steadily open stream makes much more
sense. But for simple playback of time-series or imported wave-files a function like:

using AudioIO
AudioIO.Pa_Initialize()
function soundd(sound::Vector,sampleRate::Real=48000)
    fac=div(length(sound),sampleRate);
    streamM=AudioIO.Pa_OpenDefaultStream(0,1,AudioIO.paFloat32,sampleRate,fac);
    AudioIO.Pa_StartStream(streamM);
    for i=1:fac
    AudioIO.Pa_WriteStream(streamM,convert(Array{Float32},sound[(i-1)*sampleRate+1:i*sampleRate]));
    end
    AudioIO.Pa_StopStream(streamM)
    AudioIO.Pa_CloseStream(streamM)
end 

could be of use.
The snippet above is not generic and still has errors but I guess it captures the idea.
Would this be something for AudioIO.jl or is it against the basic rationale of the package?

Seems to me there are two issues here:

  1. Right now there's no way to play an array at a sample rate other than what the stream is running at (this is issue #37).
  2. Once the stream is started by the first node that's played, it stays open indefinitely.

If the automatic samplerate conversion worked, do you still see an advantage to closing the stream after the sample finishes playing?

I think if we want to support that behavior I'd probably make it an argument to the play method rather than a whole new one.

"Output underflowed" error

Hi,

I receive an "output underflowed" error message in the julia-REPL when using the
AudioIO.jl package. The play and stop commands work as expected but after
several seconds after the play()-function finishes, i get the following warning
over and over:

julia> play(knockACc./maximum(abs(knockACc)));

julia> ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WARNING: libportaudio: Output underflowed
julia> plot(knockACc)
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WARNING: libportaudio: Output underflowed
1-element Array{Any,1}:
 PyObject <matplotlib.lines.Line2D object at 0x7f9e660a4390>

julia> ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WARNING: libportaudio: Output underflowed
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WARNING: libportaudio: Output underflowed
.... you see where this is going...

I'm not sure if this has something to do with my audio setup or
a portaudio api-call of the package.

I updated all packages. My julia-version is:

julia> versioninfo()
Julia Version 0.4.0-dev+5127
Commit 6277015* (2014-09-05 03:57 UTC)
DEBUG build
Platform Info:
  System: Linux (x86_64-unknown-linux-gnu)
  CPU: Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

[PackageEvaluator.jl] Your package AudioIO may have a testing issue.

This issue is being filed by a script, but if you reply, I will see it.

PackageEvaluator.jl is a script that runs nightly. It attempts to load all Julia packages and run their test (if available) on both the stable version of Julia (0.2) and the nightly build of the unstable version (0.3).

The results of this script are used to generate a package listing enhanced with testing results.

The status of this package, AudioIO, on...

  • Julia 0.2 is 'Tests fail, but package loads.' PackageEvaluator.jl
  • Julia 0.3 is 'Tests fail, but package loads.' PackageEvaluator.jl

'No tests, but package loads.' can be due to their being no tests (you should write some if you can!) but can also be due to PackageEvaluator not being able to find your tests. Consider adding a test/runtests.jl file.

'Package doesn't load.' is the worst-case scenario. Sometimes this arises because your package doesn't have BinDeps support, or needs something that can't be installed with BinDeps. If this is the case for your package, please file an issue and an exception can be made so your package will not be tested.

This automatically filed issue is a one-off message. Starting soon, issues will only be filed when the testing status of your package changes in a negative direction (gets worse). If you'd like to opt-out of these status-change messages, reply to this message.

Warning: libportaudio: Input overflowed

Whenever I start something playing, my julia console gets flooded with warning messages:

WARNING: libportaudio: Input overflowed

What can I do to stop that from happening?

play-stop-play doesn't work

julia> s = SinOsc(220)
julia> play(s)
julia> stop(s)
julia> play(s)

playing after stopping doesn't seem to work

design contract for buffers of AudioNode

ArrayRenderer may return a buffer that is smaller than info.buf_size, since the array might not be a multiple of info.buf_size. But InputRenderer currently asserts that the size of the input buffer must be info.buf_size.

I think the idea is that a node can signal that it is done by returning an incomplete buffer. This is the default behavior of the render function for AudioNode

It took me a while to get the idea, but play really means "hook output of node to input of mixer and input of node to output of mixer" and InputRenderer is really just a pass-through. But In general, you would want to compose nodes so that the output of one node goes to the input of another node. In fact, SinOsc{AudioNode} could have maybe been written like this, so that it took its frequency from its device_input instead of from another node.

Playing a file with a sample rate != 44100 does not work

I am trying to play a file with a sample rate of 16 kHz (using data = open('"myfile16khz.wav"); play(data), but it fails with the following exception:

WARNING: Audio Task died with exception: ErrorException("assertion failed: node.file.sfinfo.samplerate == info.sample_rate")

Apparently, the default stream for playing files and arrays is always opened considering a sampling rate of 44100 Hz, but that's not always the case. When you play a file, I think it should use the sampling rate of the file, and for arrays, you should be able to pass the sampling rate as a parameter.

If someone can give me a clue on how I could do this, I'll be happy to submit a pull request implementing this behavior.

Coordinate various audio and DSP packages

Note: This is a pretty broad issue and I imagine that as conversation develops it may get split into sub-issues, so feel free to go ahead and open up separate issues for different parts of the discussion off the bat.

After a bit of a hiatus I'm getting back into AudioIO development, and it looks like in the mean time WAV.jl from @dancasimiro made a bunch of progress integrating with various audio backends like PulseAudio and AudioQueue, and now there's FLAC.jl from @dmbates. There's also been a bunch of cool things happening in DSP.jl, and a flurry of exciting speech analysis/synthesis packages from @r9y9. I'm thinking it would be great to get the Julia audio and DSP package ecosystem working together more seamlessly.

I think it would be useful to have a common type used for audio signals and audio streams. It seems like there have been a number of explorations into this design space (@mbauman's Signals.jl and AxisArrays.jl, NamedArrays.jl, Images.jl (if we think of signals more broadly)

I'm going to be prototyping some of these ideas, but I wanted to try to get some buy-in from others in the community and try to get some advantage from your experience.

I also am interested in input from other audio processing folks (@JayKickliter, @simonster, @jfsantos, @gummif, @davidavdav). Also @timholy has thought a lot about uniformly-sampled signals and might have some insight.

Adding support for loading/saving audio formats using FileIO.jl seems like an obvious step. FileIO also distinguishes between Files and Streams, so perhaps that separation is useful here as well, if we represent audio devices as Streams.

It might be that the audio signal type is just a simple wrapper that adds some indexing convenience and keeps track of the sample rate.

Advantages of keeping the samplerate in the type:

  • we can auto-resample if the user wants to play the sound out of a stream running at a different rate
  • more easily plot on real time axis
  • specify filter parameters in real-world Hz instead of rad/sample
  • keep track of real-world frequencies when we switch into frequency domain, so plotting spectrograms can have the right axes without the user thinking about it

One thing I've thought of is to keep track of the sample rate as a type parameter so that we can have methods that decide at compile time whether they need to auto-resample or not. The frequency stuff makes me think maybe it would make sense to have AudioTimeSignal and AudioFrequencySignal. We could make it a single type and keep both domain representations, but then it's not obvious how indexing works and also tricky to invalidate one representation when the other changes.

Use Cases

Read in a wav file, save to ogg vorbis with a bitrate of 256kbps. Using the FileIO infrastructure this should look like

x = load("myfile.wav")
save("myfile.ogg", x; bitrate=256)

Read file, write first 1024 samples to new file

x = load("myfile.wav")
save("myfile_short.wav", x[1:1024])

Read file, write the first second to a new file (using SIUnits)

x = load("myfile.wav")
save("myfile_short.wav", x[0.0s:1.0s])

Read stereo file, write mono mix

x = load("myfile.wav")
save("myfile_mono.wav", x[:, 1] + x[:, 2])

Play a stereo wav file on the default audio stream

x = load("myfile.wav")
play(x)

Plot an audio signal

x = load("myfile.wav")
plot(x[:, 1]) # plots with samples on the x axis
plot(timerange(x), x[:, 1]) # plots with time on the x axis (there's probably a better name than timerange)

Semaphore seems to be getting double-waited

Currently only tested on my Linux machine, using PortAudio -> Alsa -> PulseAudio -> JACK.

Once in a while I'm seeing that the semaphore is at 0 even after the sem_post call, implying that sem_wait was called twice. I'm not sure if the callback is getting called reentrantly by the audio system or what.

The cpu_usage branch has a printf whenever the semaphore is not what it's supposed to be. I'd be interested to see if this happens on other platforms as well. I'll test on OSX tonight.

WARNING: libportaudio: Input overflowed

Attempting to use play under any circumstances seems to lead to an endless stream of warnings, although the sound does play properly.

I'm using Mac OS X 10.9.4, Julia 0.3.1, and ran Pkg.add("AudioIO") today. Here's my session:

julia> using AudioIO

julia> play([1])
INFO: Initializing PortAudio. Expect errors as we scan devices
INFO: Scheduling PortAudio Render Task...
INFO: PortAudio Render Task Running...
WARNING: libportaudio: Input overflowed
AudioNodeWARNING: libportaudio: Output underflowed
{WARNING: libportaudio: Input overflowed
ArrayRenderer}(falseWARNING: libportaudio: Input overflowed
,ConditionWARNING: libportaudio: Input overflowed
({})WARNING: libportaudio: Input overflowed
,ArrayRendererWARNING: libportaudio: Input overflowed
(Float32WARNING: libportaudio: Input overflowed
[1.0842e-19],2,Float32[1.0842e-19]))

julia> WARNING: libportaudio: Input overflowed
WARNING: libportaudio: Input overflowed
WARNING: libportaudio: Input overflowed
WARNING: libportaudio: Input overflowed

support writemime

AudioNodes and AudioFiles should support writemime (or whatever it is that you need to do to get audio controls to show up in IJulia).

No support for audio Input

The first use case is simple recording of audio into an array

In general, we probably will want to support audio input into a general AudioNode render graph, so it can be processed in real time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.