JuliaAudio / PortAudio.jl

PortAudio wrapper for the Julia programming language, compatible with the JuliaAudio family of packages
Other
115 stars 19 forks source link

small fixes to examples and README #118

Closed leios closed 2 years ago

leios commented 2 years ago

What does this implement/fix?

This is a small PR fixing typos in the README and a few examples

Reference issue

Discussed briefly here: #114

Additional information

I couldn't get the waterfall_lines.jl, lilyplay.jl or waterfall_heatmap.jl examples to run. Here are my rough thoughts on them:

  1. lilyplay.jl. I am not really sure what this one should be doing exactly, but it provides the following error:
Freude, schöner Götterfunken, Tochter aus Elisium! Wir betreten feuertrunken, Himmlische, dein Heiligthum! Deine Zauber bin den wieder, was die Mode streng getheilt, alle menschen werden Brüder wo dein sanfter Flügel weilt.
 Expression 'ret' failed in '/workspace/srcdir/portaudio/src/hostapi/alsa/pa_linux_alsa.c', line: 1742
Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm )' failed in '/workspace/srcdir/portaudio/src/hostapi/alsa/pa_linux_alsa.c', line: 1909
Expression 'PaAlsaStreamComponent_Initialize( &self->playback, alsaApi, outParams, StreamDirection_Out, NULL != callback )' failed in '/workspace/srcdir/portaudio/src/hostapi/alsa/pa_linux_alsa.c', line: 2177
Expression 'PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters, sampleRate, framesPerBuffer, callback, streamFlags, userData )' failed in '/workspace/srcdir/portaudio/src/hostapi/alsa/pa_linux_alsa.c', line: 2843
Expression 'ret' failed in '/workspace/srcdir/portaudio/src/hostapi/alsa/pa_linux_alsa.c', line: 1742
Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm )' failed in '/workspace/srcdir/portaudio/src/hostapi/alsa/pa_linux_alsa.c', line: 1909
Expression 'PaAlsaStreamComponent_Initialize( &self->playback, alsaApi, outParams, StreamDirection_Out, NULL != callback )' failed in '/workspace/srcdir/portaudio/src/hostapi/alsa/pa_linux_alsa.c', line: 2177
Expression 'PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters, sampleRate, framesPerBuffer, callback, streamFlags, userData )' failed in '/workspace/srcdir/portaudio/src/hostapi/alsa/pa_linux_alsa.c', line: 2843
Expression 'ret' failed in '/workspace/srcdir/portaudio/src/hostapi/alsa/pa_linux_alsa.c', line: 1742
Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm )' failed in '/workspace/srcdir/portaudio/src/hostapi/alsa/pa_linux_alsa.c', line: 1909
Expression 'PaAlsaStreamComponent_Initialize( &self->playback, alsaApi, outParams, StreamDirection_Out, NULL != callback )' failed in '/workspace/srcdir/portaudio/src/hostapi/alsa/pa_linux_alsa.c', line: 2177
Expression 'PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters, sampleRate, framesPerBuffer, callback, streamFlags, userData )' failed in '/workspace/srcdir/portaudio/src/hostapi/alsa/pa_linux_alsa.c', line: 2843
Expression 'ret' failed in '/workspace/srcdir/portaudio/src/hostapi/alsa/pa_linux_alsa.c', line: 1742
Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm )' failed in '/workspace/srcdir/portaudio/src/hostapi/alsa/pa_linux_alsa.c', line: 1909
Expression 'PaAlsaStreamComponent_Initialize( &self->playback, alsaApi, outParams, StreamDirection_Out, NULL != callback )' failed in '/workspace/srcdir/portaudio/src/hostapi/alsa/pa_linux_alsa.c', line: 2177
Expression 'PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters, sampleRate, framesPerBuffer, callback, streamFlags, userData )' failed in '/workspace/srcdir/portaudio/src/hostapi/alsa/pa_linux_alsa.c', line: 2843
ERROR: LoadError: PortAudioException: Device unavailable
Stacktrace:
  [1] handle_status(error_number::Int32; warn_xruns::Bool)
    @ PortAudio ~/projects/PortAudio.jl/src/PortAudio.jl:102
  [2] handle_status
    @ ~/projects/PortAudio.jl/src/PortAudio.jl:93 [inlined]
  [3] PortAudioStream(input_device::PortAudio.PortAudioDevice, output_device::PortAudio.PortAudioDevice, input_channels::Int64, output_channels::Int64; eltype::Type, adjust_channels::Bool, call_back::Ptr{Nothing}, flags::UInt64, frames_per_buffer::Int64, input_info::Ptr{Nothing}, latency::Nothing, output_info::Ptr{Nothing}, reader::PortAudio.SampledSignalsReader, samplerate::Nothing, stream_lock::ReentrantLock, user_data::Ptr{Nothing}, warn_xruns::Bool, writer::PortAudio.SampledSignalsWriter)
    @ PortAudio ~/projects/PortAudio.jl/src/PortAudio.jl:779
  [4] PortAudioStream
    @ ~/projects/PortAudio.jl/src/PortAudio.jl:721 [inlined]
  [5] #PortAudioStream#16
    @ ~/projects/PortAudio.jl/src/PortAudio.jl:842 [inlined]
  [6] PortAudioStream
    @ ~/projects/PortAudio.jl/src/PortAudio.jl:842 [inlined]
  [7] #PortAudioStream#17
    @ ~/projects/PortAudio.jl/src/PortAudio.jl:857 [inlined]
  [8] PortAudioStream
    @ ~/projects/PortAudio.jl/src/PortAudio.jl:857 [inlined]
  [9] paudio()
    @ Main ~/projects/PortAudio.jl/examples/lilyplay.jl:15
 [10] parsevoice(melody::String; tempo::Int64, beatunit::Int64, lyrics::String)
    @ Main ~/projects/PortAudio.jl/examples/lilyplay.jl:45
 [11] #12
    @ ~/builds/julia-1.7.1/share/julia/stdlib/v1.7/Distributed/src/macros.jl:43 [inlined]
 [12] run_work_thunk(thunk::var"#12#13", print_error::Bool)
    @ Distributed ~/builds/julia-1.7.1/share/julia/stdlib/v1.7/Distributed/src/process_messages.jl:63
 [13] run_work_thunk
    @ ~/builds/julia-1.7.1/share/julia/stdlib/v1.7/Distributed/src/process_messages.jl:72 [inlined]
 [14] (::Distributed.var"#96#98"{Distributed.RemoteValue, var"#12#13"})()
    @ Distributed ./task.jl:423
Stacktrace:
 [1] wait_ref
   @ ~/builds/julia-1.7.1/share/julia/stdlib/v1.7/Distributed/src/remotecall.jl:577 [inlined]
 [2] call_on_owner
   @ ~/builds/julia-1.7.1/share/julia/stdlib/v1.7/Distributed/src/remotecall.jl:567 [inlined]
 [3] wait(r::Future)
   @ Distributed ~/builds/julia-1.7.1/share/julia/stdlib/v1.7/Distributed/src/remotecall.jl:590
 [4] top-level scope
   @ ~/projects/PortAudio.jl/examples/lilyplay.jl:156
 [5] include(fname::String)
   @ Base.MainInclude ./client.jl:451
 [6] top-level scope
   @ REPL[6]:1
in expression starting at /home/leios/projects/PortAudio.jl/examples/lilyplay.jl:156
  1. waterfall_lines.jl. This one seems to be broken because of Makie.jl has changed it's API. I don't really know what ax = axis(0:0.1:1, 0:0.1:1, 0:0.1:0.5) is in modern Makie
  2. waterfall_heatmap.jl. I am not sure what the following lines are supposed to be doing:

    heatmaps = map(enumerate(IndexCartesian(), dispbufs)) do ibuf
    i = ibuf[1]
    buf = ibuf[2]
    
    # some function of the 2D index and the value
    heatmap(buf, offset = (i[2] * size(buf, 2), i[1] * size(buf, 1)))
    end

    It seems to be broken on enumerate(IndexCartesian(), dispbufs). dispbufs is a 2D array of 2D arrays and enumerate(IndexCartesian(), a) no longer exists. I tried CartesianIndices(...), but obviously i and buf are integers in this case, so heatmap(buf, offset = (i[2] * size(buf, 2), i[1] * size(buf, 1))) breaks

I'll keep working on this, I am just creating the PR prematurely to see what you think.

bramtayl commented 2 years ago

Thanks! I'm been working on this too in #107

leios commented 2 years ago

Ah, fair enough. Sorry for the spam again!

bramtayl commented 2 years ago

No problem! Let me know if you have any suggestions for #107 .