Buffer Drag to Daw

Hi guys,
I’m trying to find a way to render an AudioBuffer and drag it to the daw. Currently I have a functions that renders the waveforms in an AudioBuffer to be displayed in a component derived from Audio Thumbnail and DragAndDropContainer. The visualization works, but I can’t find a proper way to render the result as a file.

What I’m currently doing is trying to create a temporary file that will be passed to the dragger:

    File tempFile;
    StringArray filesList;
    tempFile = File::getSpecialLocation(File::userMusicDirectory).getFullPathName() + "/myPath/temp.wav";
    if(tempFile.existsAsFile()) { tempFile.deleteFile(); }
    ScopedPointer<FileOutputStream> outStream (tempFile.createOutputStream());
    if(outStream != nullptr)
        WavAudioFormat wavFormat;
        ScopedPointer<AudioFormatWriter> writer = wavFormat.createWriterFor(outStream, triSynth.getSampleRate(), outputBuffer.getNumChannels(), 24, StringPairArray(), 0);
        if(writer != nullptr)
            //const ScopedLock sl (writerLock);
            writer->writeFromAudioSampleBuffer(outputBuffer, 0, outputBuffer.getNumSamples());

update: there was a mistake in the file passed. now the file is created. I’m just wondering if there’s a better way to handle the creation of a temp file here.

Furthermore… looks like that once I dragged a file, a copy of the last dragged image will overlay to the thumbnail despite I reset it before a new drag operation begins.


ok that’s weird: the temporary file I create is correctly updated when I change the parameters. If I preview that file with Finder preview (spacebar), is sounds perfect… but if I drag a second, third, fourth time I still get the first sound I rendered.

This is not a question for JUCE but for the DAW (don’t get me wrong, it’s fine to ask here…)
So we need to know: what DAW are you testing and eventually what OS.

If you drag a wav (or any audio) file into your DAW, it usually imports the file, and if you re-import the same file, it will probably simply use the already imported one.
You might have to rename your file each time, or see if that DAW supports another way of convincing, that this is a different file…


I tried on both Ableton and Logic, getting the same result. What’s weird is that Ableton shows you the path of the file and if I delete the clip and perform a drag again, it’s pointing to the correct path but the content is not the one inside that file. I’ll try renaming and see what happens.


Ableton doesn’t copy the dragged file to the project.

…if that’s both correct, you just invented the undetectable extension charm :wink:

a) the audio is still in the memory cached
b) the displayed wave form is generated and doesn’t update, because it thinks it is still the same file

…but you probably checked also listening to it…

1 Like

That also happens in Logic Pro X and yes… I checked the generated file and is what it should meant to be. The file is explicitly deleted before being recreated, so I can’t figure out what the problem is.
If I create files with different names, it works as expected and the content of the file is correct, but I find a bit insane that I have to create dozen of files.

Yes… that true. In fact if I drag the files to a Logic project, save, close and reopen, I find all the exported samples in the project… while in Ableton Live, just the last one.

Protools is very well behaved. Copies everything to the project folder.

I might try encouraging Ableton to provide the same feature again…

So… looks like I have to set an option to delete the temporary wav files created or not, otherwise the users will suffer this above issue.

it is normal that, after performing a dragging, there’s a sort of residual image on top of the dragged component?