[Stk] FileWvOut to append the sound

Pavel Nikitenko pavn at centrum.cz
Mon, 03 Mar 2008 22:37:29 +0100


Hi Gary,

I already tried to do it, but the header of sound file needs to be 
updated as well, that is why this complicates the scenario for all of 
the supported formats there.
I put there "wb" for this purpose and tried to update header for aif 
file for now. However I need to spend more time on it since it did not 
work correctly yet for me completely.
>
> To do it correctly, we should add a constructor flag that specifies 
> whether to overwrite or append. 
I think this is good way so only one class would be used for either 
overwrite or append.

> But the change is complicated because the actual file opening is 
> embedded in the FileWrite class.
I tried to do it with copy of classes with FileWriteA and FileWvOutEx(A) 
for now.
But need to spend more time on it. Since it did not work with my simple 
changes which looked should help.
I do not know much about exact aif, wav and other file formats that is 
why this complicates things to me.

There should be some universal functions which will read sound file 
header to header structure in open file like functions in 
FileRead::getXXXInfo() and update that header in file before the file is 
closed based on previous obtained information from header and also new 
recorded data size. Also the class should provide correct time in frames 
using some function in this mode so it will allow to report the complete 
stored audio time in frames. Both complicates thing. I am going to work 
on this tomorrow.

If you could cooperate with me on it that would be quite helpful.

--Pavel

Gary Scavone wrote:
> Hi Pavel,
>
> To do it correctly, we should add a constructor flag that specifies 
> whether to overwrite or append.  But the change is complicated because 
> the actual file opening is embedded in the FileWrite class.  If you 
> simply want to make a quick change for your own purposes, then you can 
> search for the "fopen()" function in FileWrite.cpp (several instances) 
> and replace the "wb" argument with "a" (it turns out the 'b' is no 
> longer necessary).
>
> Regards,
>
> --gary
>
> On 25-Feb-08, at 4:18 AM, Pavel Nikitenko wrote:
>
>> Hello,
>>
>> I use FileWvOut class for audio recording to file. But I observed, that:
>> wvOut = new FileWvOutEx(name, channels, FileWrite::FILE_AIF, 
>> Stk::STK_SINT16, 1024);
>>
>> always opens new file and overwrites existing.
>> Could you help me/advice modification to FileWvOut to be able to 
>> append to existing file, instead of overwrite.
>>
>> Thanks in advance,
>>
>> Pavel
>>
>> _______________________________________________
>> Stk mailing list
>> Stk@ccrma.stanford.edu
>> http://ccrma-mail.stanford.edu/mailman/listinfo/stk
>
>
>