Integrate Bungee with Juce

Hi, has anyone successfully integrated the Bungee pitch shifter library into their JUCE project? They provided a working example, but it’s for a command line case. I’ve tried to make it work, but there’s no output audio:

auto buffer = bufferToFill.buffer;
    auto sampleCount = buffer->getNumSamples();
    auto writePtr = buffer->getArrayOfWritePointers();
    auto readPtr = buffer->getArrayOfReadPointers();
    auto pushFrameCount = processSpec->maximumBlockSize;

    InputChunk inputChunk = stretcher1->specifyGrain(stretcherRequest);
    Push::InputBuffer pushInputBuffer(stretcher1->maxInputFrameCount() + pushFrameCount, processSpec->numChannels);
    pushInputBuffer.grain(inputChunk);

    int position = 0;
    while (position < sampleCount)
    {
        // Get the next block of audio
        mixerSource.getNextAudioBlock(bufferToFill);

        // Copy data to pushInputBuffer
        int framesToCopy = std::min(static_cast<int>(pushFrameCount), sampleCount - position);
        float* inputData = pushInputBuffer.inputData();
        for (int c = 0; c < processSpec->numChannels; ++c)
        {
            for (int i = 0; i < framesToCopy; ++i)
            {
                inputData[c * pushInputBuffer.stride() + i] = readPtr[c][position + i];
            }
        }

        // Deliver the input frames
        pushInputBuffer.deliver(framesToCopy);

        // Process available input
        while (pushInputBuffer.inputFrameCountRequired() <= 0)
        {
            stretcher1->analyseGrain(pushInputBuffer.outputData(), pushInputBuffer.stride());
            OutputChunk outputChunk;
            stretcher1->synthesiseGrain(outputChunk);
            stretcher1->next(stretcherRequest);

            // Write the output chunk to your buffer
            for (int c = 0; c < processSpec->numChannels; ++c)
            {
                for (int i = 0; i < outputChunk.frameCount && position + i < sampleCount; ++i)
                {
                    writePtr[c][position + i] = outputChunk.data[c * outputChunk.channelStride + i];
                }
            }

            position += outputChunk.frameCount;

            inputChunk = stretcher1->specifyGrain(stretcherRequest);
            pushInputBuffer.grain(inputChunk);
        }
    }

Appreciate any help. Thanks

We tried to get it working, and gave up. Switched to SignalSmith Stretch and it works great for our use case.

Bungee looks very promising especially for realtime adjustments but it’s a very low-level API. SignalSmith’s in comparison is just a few lines of code and it “just works”.

2 Likes

@adamwilson Does SignalSmith have better performance than Bungee? I tested on Web and observe that Bungee has a relatively good performance

I don’t know, we didn’t get that far. SignalSmith serves our needs well enough. Bungee seems very well thought out, especially for realtime adjustments, but it suffers from a difficult to use API without clear documentation. At least this was the case a few months ago.

1 Like

It seems that Chowdhury DSP is working on this:

2 Likes

very cool, has anyone experimented with chowdhury implementation of bungee? anyway, i might give it a try in the next few days and report back

Bungee creator here. Integrating Bungee into Juce projects should be much easier now since we created a wrapper for the close-to-the-metal Bungee.h API.

There is sample usage of this API here: bungee/cmd/main.cpp at e5a1b1f87e9a3e9bf5dad4673bd4366c9f095c31 · bungee-audio-stretch/bungee · GitHub

Shout if I can help with anything!

3 Likes

Hi Adam, I’m trying to use SignalSmithAudio, can you give me some help about it? I can compile but it doesn’t stretch :slight_smile:

Would you mind sharing how you made it work, been trying for weeks to have time stretching but just cant work

If it worked , please share, been struggling with it for weeks

Did you ever make it work, how did you?

Are you referring to SignalSmith Stretch, or Bungee?

I meant signal smith, but got it figured out

It actually works just fine

1 Like