ToxVox
January 15, 2022, 12:35pm
1
I created an empty clip ( wave type). How do I insert an audio file after a created clip?
Here is the way I created the empty clip:
auto clip = audioTrack->insertNewClip (te::TrackItem::Type::wave, "WaveAudioClip", editTimeRange, nullptr)
I know there is a way with insertWaveClip()
. But for my function I have to add it afterwards.
Haven’t tried myself, but maybe this method could be useful?
WaveAudioClip::addTake (const juce::File& f)
ToxVox
January 15, 2022, 1:34pm
3
I already tried it but didn’t work for me.
dave96
January 15, 2022, 1:49pm
4
You probably don’t want to add a take. Use Clip::getSourceFileReference
Hey @ToxVox
I’m not sure if this helps but what I’ve been doing is:
juce::File blah {"path"};
auto clip = audioTrack->insertNewClip (te::TrackItem::Type::wave, "WaveAudioClip", editTimeRange, nullptr)
clip.setCurrentSourceFile(blah);
In my case I was swapping around audio files in to clips. Seems like it might work in your case too. Apologies if I misunderstand!
Cheers, J
dave96
January 17, 2022, 10:27am
6
You don’t typically want to use setCurrentSourceFile
as that won’t save the path to the Clip so it won’t get recalled when you load the session again. This just sets it temporarily for playback.
1 Like
ToxVox
January 18, 2022, 8:01pm
7
This version works for me:
juce::File blah {"path"};
auto clip = audioTrack->insertNewClip (te::TrackItem::Type::wave, "WaveAudioClip", editTimeRange, nullptr);
clip->getSourceFileReference().setToDirectFileReference(blah, true);
Or should I use this function? SourceFileReference::setToProjectFileReference()
dave96
January 31, 2022, 11:04am
8
You won’t be able to use this unless you’re managing resources using a te::Project
which isn’t advised practice now.