AudioTransportSource cropping

Hi

I have an AudioTransportSource and I want to allow cropping, so I want to write a function that will receive it with startPosition and endPosition and will
return a new AudioTransportSource.

What will be the best way to achieve that?

Should I use an AudioFormatWriter::writeFromAudioSource to a new MemoryBlock and then create a new AudioTransportSource from it?

Thank you

So you mean a custom source that takes your input source and reads from a different section of it? There’s no need to write to a memory block, is there? You could just redirect the incoming read requests to read from a different position in the source.

I tried to do it (change the start position) but there was a delay between when it ends playing and then starts again (loop mode)

The memory block version is working well, but it’s a kind of a workaround, maybe I should find a way to write something like a CroppableAudioSource that will inherit from AudioSource.

AudioSubsectionReader?

1 Like

Opps… Thanks Jules

It works well, if I’m about to use it to allow custom-range looping of an audio, do I need to create an instance of it for each loop and then do transportSource.setSource(), is there a problem that prohibit adding a setLoopRange() in the AudioSubsectionReader()?

I don’t think that looping should be the responsibility of the AudioSubsectionReader.