erlaudio
erlaudio copied to clipboard
I have {:error, :timeout} when I try to stream something
Hello, I'm trying to use your library but I have tome problems. when I try to play some sound, the first call to stream_sound make sound, but not the second time. Do I have to do something special? I'm on mac os. Thanks in advance!
ip = :erlaudio.default_input_params(:int32)
op = :erlaudio.default_output_params(:int32)
{:ok, handle} = :erlaudio.stream_open(ip, op, 22050.0, 1024)
noise = <<114, 186, 243, 129, 80, 153, 235, 171, 123, 153, 37, 54, 179, 41, 143, 56, 118, 108, 2, 144, 122, 103, 80, 16, 149, 254, 85, 48, 52, 9, 228, 215, 213, 84, 65, 208, 5, 7, 13, 14, 253, 144, 156, 100, 171, 225, 229, 204, 150, 76, ...>>
:erlaudio.stream_start(handle)
:erlaudio.stream_write(handle, noise)
:erlaudio.stream_write(handle, noise)
The stream might be closing because of an input overflow. I ran this with ip being :null
, and it worked. Leave this open as a bug for me to come back to later and "fix". This should've thrown an error.
It seems to work for me if I close the stream after something is streamed. Otherwise I don't have sound if I write something the second time.
Like :
def play(handle, file) do
{:ok, wave} = File.read(file)
:erlaudio.stream_write(handle, wave)
:erlaudio.stream_start(handle)
:erlaudio.stream_stop(handle)
end
oops the function doesn't work all the time either :(