Off line processing in memory, which class to use?

To learn more I thought I’d alter the tutorial Draw audio waveforms so it works on audio data loaded into memory. The idea was to process this audio data in various ways.

I tried to use MemoryAudioSource, and it kind of works but it seems to get too complicated getting the things together so that views, playback and positioning updates when the buffer held by MemoryAudioSource is altered.

Which is the suggested class to use for this kind of off line audioprocessing in a standalone?

The ideal would be easy processing of the buffer and also making updating of AudioThumbnail and AudioTransportSource smooth and logical. Maybe MemoryAudioSource is not at all intended for this? Or perhaps the tutorial is a bad starting point for a more general case?

Any help to find the right Juce class for this purpose is appreciated. :slightly_smiling_face:

One possibility might be to make your own MemoryAudioSource kind of class, but with a feature where the used AudioBuffer can be easily and safely switched and/or processed. (The MemoryAudioSource is a simple class, making your own equivalent shouldn’t be too difficult.) Note that I haven’t tried that myself and there might complications when for example the AudioTransportSource class is also involved.

OK, thanks.

Reading a bit further it seems like some functionality would be easier if I represent the data as an InputStream.
E.g. in one case I could use: AudioThumbnail::loadFrom ( InputStream & *input* ) which would make things easier when updating graphics, there’s no equvalent for MemoryAudioSource unfortunately.

However I need to understand streams first there’s no tutorial or example, where would I start to get a grasp on the pros and cons and difference between using streams (e.g. MemoryInputStream) or sources (e.g. MemoryAudioSource)?

Please have a closer look at the docs:
AudioThumbnail::loadFrom (InputStream&)

Reloads the low res thumbnail data from an input stream.

This is not an audio file stream! It takes a stream of thumbnail data that would previously have been created by the saveTo() method.

Basically if you load audio data an AudioFormatReader is somehow involved, while InputStream and it’s descendents read raw file streams.

I think you can consider using MemoryMappedFile. You do not need to care where to load and how to manage a big amount of audio data, just have a pointer to data which you can use as you want.

The original poster wants to be able to modify the audio data as a buffer, MemoryMappedAudioFormatReader doesn’t allow that.

Thanks, I missed that.

So if I want to redraw my thumbnail after processing the buffer the way to go is:


…adding the updated block, which in my case is the same block. There’s no way to make the thumbnail “redraw” without explicitly sending the buffer every time?

Perhaps there’s a better concept for modifying audio offline than on a buffer? I’m quite new to Juce so I don’t have the overview of all the classes to make the optimal choice I think.