does anybody know how to modify the buffer contents of
an AVAudioPCMBuffer object? I want to do the following:
load an audio file into an AVAudioPCMBuffer - this works.
modify the samples data of the AVAudioPCMBuffer. - here i stuck
write the AVAudioPCMBuffer to a file - this also works.
as in the documentation layed out, the AVAudioPCMBuffer.floatChannelData
is unfortunately read-only. Also the itAudio.audioBufferList.memory.mBuffers.mData seems to be read-only.
the compiler shows: cannot assign through subscript: subscript is get-only. currently i am using the audiotoolbox, which works fine for my
purposes. nevertheless i would like to ask if anybody knows the (best practice) way for doing this job?
thanks a lot for any help!!!
Related
I'm working on a script to convert a Simulink library to a plain model, meaning it can be simulated, it does not auto-lock etc.
Is there a way to do this with code aside from basically copy-pasting every single block into a new model? And if it isn't, what is the most efficient way to do the "copy-paste".
I was not able to find any clues as how to approach this problem here, or on Google, or on the official documentation or on the MathWorks forum so I'm at a loss on how to proceed.
Thank you in advance!
I don't think it's possible to convert a library to a model, but you can programmatically add library blocks to models like so:
sys = 'testModel';
new_system(sys);
open_system(sys);
add_block('Simulink/Sources/Sine Wave', [sys, '/MySineWave']);
save_system(sys);
close_system(sys);
sim(sys);
You could even use the find_system command to list all the blocks in a library and then loop through them all and create a new model for each using the above code.
I'm using the VideoWriter object to create a movie in Matlab. However, the movie file doesn't write until the program stops.
Is there any way to force it to write as it's going? Looking online I don't see anything.
I'm currently writing to as an avi but I don't care which format I use.
please specify your findings and search result for what you have already tried
I am trying to change the value of a tag from a TIFF object in my matlab code. I keep getting this error:
Error using tifflib
Tag number (273) is unrecognized by the TIFF library.
Error in Tiff/setTag (line 1146)
tifflib('setField',obj.FileID, ...
The code I am using is included below:
fname='C:\FileLocation\pcd144_012.tif';
t=Tiff(fname,'r+');
t.getTag('StripOffsets')
t.setTag('StripOffsets',[8, 16392])
Why is it I can get the tag and see it, but cannot set the tag to a different value?
Here is a link to the tiff I am working with:
Tiff Data
I think that you're out of luck with this approach. The setTag methods are mostly used when building a TIFF from scratch. My guess is that the 'StripOffsets' field is not modifiable. Keep in mind that these tools are designed for the normal case of non-broken image files and that changing this field in such cases would either break the file or necessitate re-encoding of the data most of the time. The function should give better feedback (documentation for the TIFF could be better in general) so you might still contact The MathWorks to let them know about this.
As far as finding a way to edit these tags/fields, you might look for and try out some TIFF tag viewer/editor programs to see if they might do it. Otherwise it may come down to parsing the header yourself to find the relevant bytes.
I am trying to save a variable in .mat format and update and APPEND the NEW contents of THIS variable each time a loop is finished to avoid memory blow up. I have searched a bit and think the best way is structures. But still think there should be an straight way to do that. Anybody can give me an example to how to do that?
You could try using matfile to write without loading the file.
I'm using the following function:
_alutLoadWAVMemory_((ALbyte *)myBuf,&format, &data, &size, &freq, &loop);
I have 2 questions:
I've read online that the function is deprecated, does anyone know why? More important - what should I use instead?
Is the variable format assigned with data regarding the format after I call _alutLoadWAVMemory_?
Thanks a lot!
There are a few candidates for functions to use instead, see the Alut documentation on loading. I think the closest equivalent to LoadWAVMemory would be 'alutCreateBufferFromFileImage'.