How to use Clip Effects?

The following is not working, I just get silent audio :

if (clip->canHaveEffects())
			{
				clip->enableEffects(true, false);
				te::ClipEffect::createEffectAndAddToValueTree(edit, clip->state, te::ClipEffect::EffectType::reverse, 0);
				
				
			}
			else
				Logger::writeToLog("Can't have clip effect");

Note: Clip effects work with Audio clips, but not MIDI clips or Step clips.

From the manual, how do you have your clip setup?

Edit; NM I see you are trying to use audio.

It’s a clip playing an audio file.

Let me know if you get it, I will do the same.

I think the effect needs to be added to the EFFECTS node which is a child of the AUDIOCLIP called and added by the enableEffects call (see AudioClipBase::enableEffects) then do:

clip->enableEffects (true, false);
ClipEffect::createEffectAndAddToValueTree (clip->edit, clip->state.getChildWithName (IDs::EFFECTS),
                                           te::ClipEffect::EffectType::reverse, -1);
1 Like

OK, it worked for the reverse effect but for example the stepVolume processing isn’t working. Maybe I need to set some parameters for it, but the edit’s XML seems to have sensible looking default things anyway…?

<EFFECTS>

<EFFECT type=“stepVolume” noteLength=“0.25” crossfadeLength="0.01000000000000000021"

pattern=“1010101010101”/>

</EFFECTS>

Looks ok to me.
I’d have to see the use case to know more.

Maybe step in to the rendering to see if the file is being created correctly? Maybe it’s getting a zero length from somewhere?

I am still doing this with the PitchAndTimeDemo code.

I just tried this out and it seems to render correctly. The audio is correctly gated (sounds like a very low frequency tremolo).

OK, very odd. It is now working here too…I did manually clean up the temporary files folder before retesting, though…

1 Like

It looks like this call in the destructor of the demo component is maybe not working, then?

edit.getTempDirectory (false).deleteRecursively();

Works for me on the Mac.

Are you on Windows? It might be that if the Edit is still playing it has open file handles and Windows doesn’t seem to like that. If you clear the thumbnail and call transport.freePlaybackContext(); before deleting the files does it work?

Also, maybe try checking the return value of edit.getTempDirectory (false).deleteRecursively();?

thumbnail.setFile({});
transport.freePlaybackContext();

Is not enough to allow the temp files deleting to succeed. And yes, this is on Windows.

Try engine.getAudioFileFormatManager().releaseAllFiles();?

This seems to work :

engine.getAudioFileManager().releaseAllFiles();

No releaseAllFiles method in AudioFileFormatManager. :wink:

Ah that’s what I meant. Glad that works.
I’ll try and update that and add some assertions.

@dave96 How can I ensure the thumbnail image gets updated when using the Clip Effects? Calling

thumbnail.setFile(EngineHelpers::loopAroundClip(*clip)->getPlaybackFile());

immediately, or even with a slight delay, after enabling and setting the Clip Effects does not work. Is there some kind of a notification system, or should I set some render progress variable somewhere or …?

I am implementing my own Clip Effect type, so I’ve probably made some mistake somewhere but the Tracktion Engine provided Clip Effects fail to update the thumbnail sometimes too…This is still in the context of the PitchAndTimeDemo.

edit : actually, setting the thumbnail file after a long enough delay with a timer seems to work. But shouldn’t this work a bit more automatically, after all, the Clip Effect renders can take quite a variable amount of time to finish?

I think if you register as a SelectableListener, you’ll get a void selectableObjectChanged (Selectable*) callback when the source file changes. In here you can get the playbackFile and set the thumbnail to it?

1 Like

OK, that kind of works but I get a bit too many calls into the selectableObjectChanged method. I get glitchy playback because setting the thumbnail file also seeks the playback or something…

I don’t think it should do any seeking if you’re just using the demo code.
Are you doing just

thumbnail.setFile (clip->getPlaybackFile());

without the loopAroundClip bit?