Playrec - Forum

Multi-channel Matlab Audio

You are not logged in.

#1 2008-02-19 17:26:51

smallstone
Guest

fading audiodata

hello!

first of all i want to say that 'playrec' is a very useful tool! good work! thank you very much!

my suggestion is, to implement a possibility to fade out the audiodata during playback. so if a user presses a stop or pause button within an application, the playback fades out wihtin a short (adjustable?) time and stops playback. that would be very useful!

greetings!

smallstone

 

#2 2008-04-19 23:21:31

Rob
Administrator
Registered: 2007-12-23
Posts: 54

Re: fading audiodata

This kind of functionality could be added within Playrec, although it goes against the idea that Playrec should pass the data between Matlab and soundcard with as little manipulation as possible.  I would suggest your use case could be implemented fairly simply in Matlab, fading the data before supplying it to Playrec - you could even implement the fades over multiple pages without much difficulty.  The extra latency for the pause/stop to take effect when implemented like this would not be obviously noticeable to the user.

Hope this helps.

Offline

 

#3 2009-01-13 23:24:10

mvandam
New member
Registered: 2009-01-13
Posts: 3

Re: fading audiodata

I have a question/request in a similar vein, but I don't think it could be managed with the suggested solution.  I'd like to use Playrec to play a prerecorded stimulus file and record the spoken response.  A listen-and-repeat task.  The duplex and low-latency features of Playrec are advantages for this.

I have a script that records during playback and response (what I want), but I can only get it to work for some specified page/buffer size that is sometimes too big, but should never be too small.  What I'd like is a way to interrupt or kill the record/playback and return control to the script, say with an *escape* or *break* command of some sort.

For example, suppose I set the page size to play & record for 10 seconds.  The playback concludes at 1.2 sec (and that playback is actually recorded in the soundfield, which is good), and the response is over by 4.1 seconds.  I'd like to be able to then turn control back over to Matlab (either by a human hand, or, say, automatically when the amplitude drops off below some threshold) to go to the next iteration of the loop--not have to wait 5.9 sec for the recording to finish.

Many thanks for a reply or workaround.

    -Mark

Offline

 

#4 2010-05-29 11:43:44

Rob
Administrator
Registered: 2007-12-23
Posts: 54

Re: fading audiodata

I know this message is very old, but will provide a suggestion just in case anyone else is interested.

The way to do this is to record in much shorter segments.  For example, request Playrec to record ten x 1 second long pages at the start, keeping track of the page numbers returned from the 'rec' command.  There will be no samples missing between these recordings, so if you get all 10 recordings once they've completed and join them back together this is the same as doing one x 10 second recording.  The advantage of this approach is that Matlab can wait for, and then check, each 1-second recording before the entire 10seconds has elapsed.  If it 'decides' to end the recording early it can just delete the remaining recording page requests and carry on without problems.  The opposite can also be true - if it decides it's getting near to the end of the 10 seconds and needs to record more then it can just send more recording requests to Playrec.

This approach can also be used with playback and recording simultaneously.  In the original question it is very unlikely the user will want to interrupt during the 1.2 second initial playback, so that could all be sent as a single page, followed by recording only pages thereafter.

The philosophy behind Playrec was that it provided a very versatile method of playing and recording samples but without it having to do any processing whatsoever to those samples - Matlab's there to do all the data processing!

Offline

 

#5 2010-05-30 18:18:29

mvandam
New member
Registered: 2009-01-13
Posts: 3

Re: fading audiodata

Rob,  thanks for the reply, even though the post was indeed a long time ago.

I solved the problem a little differently.  Allow the playRec function go for the predetermined maximum (10 sec in this case) for every trial, and (have a different Matlab process) monitor for a specific key press (eg, F12) indicating the end of that trial as operator feedback.  The difference between time-key-press and time-playback-start is the total desired duration of the file.  Although the whole 10 seconds is in the buffer or written to a local variable, only the desired amount is written out to file.

This works fine if the pace isn't too rapid and if you have enough memory--which for my application, both conditions are satisfied.

    -Mark

Offline

 

#6 2010-08-20 09:59:49

hero_hont
New member
Registered: 2010-08-20
Posts: 5

Re: fading audiodata

mvandam wrote:

Rob,  thanks for the reply, even though the post was indeed a long time ago.

I solved the problem a little differently.  Allow the playRec function go for the predetermined maximum (10 sec in this case) for every trial, and (have a different Matlab process) monitor for a specific key press (eg, F12) indicating the end of that trial as operator feedback.  The difference between time-key-press and time-playback-start is the total desired duration of the file.  Although the whole 10 seconds is in the buffer or written to a local variable, only the desired amount is written out to file.

This works fine if the pace isn't too rapid and if you have enough memory--which for my application, both conditions are satisfied.

    -Mark

hih, you..
i am studing maltab.
do you know with loop in the matlab, when we write code at the command, ex: i am using loop if and while or for?
diffifent about loop if and while?
ah, why do command " goto: it haven't in the matlb?
please reply?
have a nice week..
wish your health and your success...

Offline

 

#7 2010-08-20 15:55:37

mvandam
New member
Registered: 2009-01-13
Posts: 3

Re: fading audiodata

there is no "goto" command in Matlab.  The usual way to accomplish this (slowly) is using the required FOR, WHILE, IF, TRY, CATCH, etc loops.  There are surely other ways (such as accessing indicies of a matrix--which is typically much faster in Matlab), but you'll need to tailor them to your application and needs.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2008 PunBB