octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GSoC audio callbacks


From: Mike Miller
Subject: Re: GSoC audio callbacks
Date: Sun, 25 Aug 2013 18:05:29 -0400

On Sun, Aug 18, 2013 at 00:52:29 +0300, Vytautas Jancauskas wrote:
> On Tue, Aug 13, 2013 at 8:56 PM, Mike Miller <address@hidden> wrote:
>> Hi Vytautas,
>>
>> I took a look at the latest audio feature you added, callback
>> functions for playback and recording [1]. For everyone else following
>> along, this is an Octave extension that will allow a user function to
>> supply or consume an audio stream in real-time rather than storing the
>> entire signal in memory.
>>
>> [1] 
>> http://gsoc2013octaveaudio.blogspot.com/2013/08/writing-portaudio-callbacks-in-octave.html
>>
>> I had better luck with the playback, and it definitely worked better
>> for me than when I tried it the week before. There were still some
>> issues with playback, though, and I didn't get much success from
>> recording.
>>
>> Playing audio with a callback:
>>
>> I created a white noise function and got playback working relatively easily:
>>
>>   function [y, status] = generate_sound (n)
>>     y = randn (n, 1);
>>     status = 1;
>>   endfunction
>>   player = audioplayer (@generate_sound);
>>   play (player);
>>
>> This did run for quite some time with no problem. I couldn't find
>> where the status return value was used, so I didn't try different
>> values there. Eventually (tens of seconds, maybe a minute or two), the
>> sound changed from white noise to a buzz and I got an error about some
>> value not being defined. When I tried to stop and play the player
>> object again, Octave crashed. I will try to reproduce this and get
>> some more debug information.
>>
>
> See if this still happens after the latest changes.

I can still occasionally get the player with a callback function to fail with:

  error: 'n' undefined near line 2 column 12
  error: evaluating argument list element number 1
  error: called from
  error:  .../play.m at line 2, column 3

and also occasionally the player object itself becomes undefined in my
workspace somehow.

>> Recording audio to a callback:
>>
>> I tried to do the same with recording, but for some reason the
>> callback function was only called after I called the stop method. I
>> did something simple like this:
>>
>>   function do_record (left, right, n)
>>     disp (n);
>>   endfunction
>>   recorder = audiorecorder (@do_record);
>>   record (recorder);
>>   stop (recorder);
>>
>> The number "512" was displayed once, and only after calling stop.
>>
>
> This is because you don't return a status value. Return 0 to continue
> playback 1 if you want to stop cleanly and 2 if you want to stop
> abruptly.

Ok, this works for me now, have not tested too thoroughly though.

Recording to a matrix isn't working for me anymore. No matter how I
construct the recorder object, it always has zero samples after
recording for any length of time, and getaudiodata returns a 0x2
array.

I briefly tested audioinfo, audioread, and audiowrite, this looks like
a good start too. I'm able to read and write au and wav files with no
problems. Have you done any testing with encoded formats that I think
sndfile should support, e.g. ogg vorbis or flac? I wasn't able to get
much out of trying to read or write ogg vorbis files. Audioinfo did
return some correct metadata.

Keep up the good work,

-- 
mike


reply via email to

[Prev in Thread] Current Thread [Next in Thread]