jamoma / JamomaCore

Jamoma Frameworks for Audio and Control Structure
Other
36 stars 14 forks source link

Improve syntax for instantiating TTBuffer in C++ #194

Closed nwolek closed 10 years ago

nwolek commented 10 years ago

In my attempts to quit using deprecated TTObjectBaseInstantiate & TTObjectBaseRelease methods, I find the syntax for making TTBuffer work feels very unintuitive.

https://github.com/jamoma/JamomaCore/blob/dev/DSP/extensions/SoundfileLib/tests/TTSoundfileLoader.test.cpp#L197

I am essentially having to check out TTSampleMatrixPtr via TTObjectBasePtr, which does not feel right. Ideally, I would want something like this...

TTBuffer myBuffer(2,"aBufferByAnyOtherName");
myBuffer.set("lengthInSamples", 22050);

TTSampleMatrixPtr letsGetSomeSamples = NULL;
myBuffer.checkOutMatrix(letsGetSomeSamples);

TTSampleValue sample = letsGetSomeSamples->peek(0,0);

I used to be able to do something similar with the deprecated methods. It feels like I lost some functionality in the transition, but maybe I am missing something.

Could not seem to make it happen in spite of my attempts to create a public constructor for TTBuffer. May need @tap to collaborate with me on a solution for this.

nwolek commented 10 years ago

Wondering if the wrapping of TTAudioSignal here could be a model: https://github.com/jamoma/JamomaCore/blob/dev/DSP/library/includes/TTAudioObject.h#L24

nwolek commented 10 years ago

Or maybe we could add TTSampleMartix* to this union to enable passing via TTValue: https://github.com/jamoma/JamomaCore/blob/dev/DSP/library/includes/TTAudioObject.h#L24

nwolek commented 10 years ago

As of commit f4d6bae, I made some progress on the wrapper here: https://github.com/jamoma/JamomaCore/blob/dev/DSP/library/includes/TTBuffer.h#L185

You can see the syntax in action here: https://github.com/jamoma/JamomaCore/blob/dev/DSP/extensions/SoundfileLib/tests/TTSoundfileLoader.test.cpp#L194

I still need to flesh out the wrapper some more, but this shows that it will work. Should make accessing buffers inside the C++ code much cleaner.