Multichannel audio


#1

Hi All,

question: does Juce support multichannel audio?
I’m on OSX and need to have some multichannel support.
In the end I need to have 6 channels of audio via the 7.1 hdmi output.
I’d like to have the 6 channels of audio in a multichannel (8 channel, with 2 channels silent) wav file.

Is this somehow possible?
I also tried using the audio thumbnail functions, but it crashes on opening a multichannel file.

Thanks,
Patrick


#2

AFAIK, JUCE supports a maximum of 2 channels for output (stereophonic).


#3

hmm, that would be a pitty…

I tried Processing, OpenFrameworks, and some first steps in CoreAudio (which seem to seriously lack documentation).
Anyone any other ideas?

Patrick


#4

Definitely not true. Juce supports whatever the operating system offers in terms of output channels for the selected driver.

I know this for sure because my app lets you assign output channels and I have assigned six channels to my FireFace 400.


#5

WhatVIncentSaid++; Just make a little test application and try it out!


#6

WhatVIncentSaid++; Just make a little test application and try it out![/quote]
well thats what i did. but i can only test it at the moment using an aggregate device, and it doesn’t work.
It only plays on first 2 channels of aggregate device.

And like i said, audiothumbnail on a wavfile with >2 channels just crashes :frowning:


#7

Juce supports it, yes. Whether the file helpers for each flavor support it is another question.

What type of file?

Bruce


#8

In what app? More likely to be the code that uses the thumbnail which is at fault, rather than the thumbnail code, but if you can show me some code that should work but crashes, then I’d obviously want to see that!


#9

:shock: Woops! After reading the posts, I see that I’ve been missing out… I realized that I had to update my driver to get control over my speaker configuration (7.1 maximum - which all channels are available to me in JUCE)! Sorry! :?


#10

In what app? More likely to be the code that uses the thumbnail which is at fault, rather than the thumbnail code, but if you can show me some code that should work but crashes, then I’d obviously want to see that![/quote]

void AudioClip::openFile() {
    label = new Label (T("File: "), currentFile->getFileName());
    label->setBounds (1, 1, 280, 20);
    addAndMakeVisible(label);
    audiosystem->reader = audiosystem->formatManager->createReaderFor(*currentFile);
    if (audiosystem->reader != 0)
    {
        audiosystem->readerSource = new AudioFormatReaderSource(audiosystem->reader,true);
        audiosystem->audiotransportsource->setSource(audiosystem->readerSource, 32768,audiosystem->reader->sampleRate);
        audiosystem->audiosourceplayer->setSource(audiosystem->audiotransportsource);
        hasFile=true;
        thumbnail = new AudioThumbnail(128, *audiosystem->formatManager, *audiosystem->thumbnailcache);
        FIS = new FileInputSource(*currentFile);
        thumbnail->setSource(FIS);
        thumbnail->addChangeListener(this);
    }
    else
    {
        DBG("Could not create reader");
    }  
}

this is my code that opens fine.
Works with mono and stereo wav files, but crashes on multichannel files.

it crashes in the juce::findMinAndMax(int const*, int int& int&) function in juce_MathsFunctions.h on line 168:
Type mn (*values++);

Program received signal EXC_BAD_ACCESS.

Thanks for your help all…
Patrick


#11

Thanks Patrick, but before I spend time investigating, are you definitely using the very latest version (modules branch)?

(And when reporting crashes, please always give a stack trace. There’s really no point that findMinAndMax crashes, because obviously the important thing to know would be why that function is getting called with a duff parameter).


#12

I’m using JUCE v1.54.27 (downloaded today from sourceforge again).
Is it better to use the git version?

How can I export a stacktrace in Xcode 4 when it goes in debugmode (after the application crashed)?

#13

Yes! There’s no point telling me about bugs in code that’s 6 months out-of-date!


#14

So, how can i check for certain i’m using the latest version?
juce_amalgamated.h in git still has the same version number:

#define JUCE_MAJOR_VERSION	  1
#define JUCE_MINOR_VERSION	  54
#define JUCE_BUILDNUMBER	27

I think I compiled my app using the updated version (using the introjucer update function), and it still crashes at the same point…


#15

The latest is 2.0.x


#16

So, after a lot of fiddling i’m now using the latest Juce version (JUCE v2.0.16).
My application runs, and reads stereo files, but it still crashes on the multichannel wav file.

One thing i noticed is the function AudioFormatReader::readMaxLevels.

It takes reference parameters for lowestLeft, lowestRight etc.
How is this supposed to work with multichannel files, where there is no “left” or “right” ?


#17

Post a small command line program that demonstrates the bug


#18

I don’t really know how to create a commandline app that uses AudioThumbnail… :cry:


#19

I don’t really know how to create a commandline app that uses AudioThumbnail… :cry:[/quote]

You can create the thumbnail without displaying it…


#20

Quick & dirty fix… only the first 2 channels’ min & max values are passed around for the thumbnail…

In juce_AudioFormatReader.cpp

in the function: AudioFormatReader::readMaxLevels

With usesFloatingPointData == false the function attempts to read beyond the memory bounds for tempBuffer if you have more than 3 channels…

Change:

int* tempBuffer[3]; tempBuffer[0] = tempSpace.getData(); tempBuffer[1] = tempSpace.getData() + bufferSize; tempBuffer[2] = 0;

to:

[code] int* tempBuffer[numChannels+1];
tempBuffer[0] = tempSpace.getData();

int k;

for (k = 1; k <= numChannels; k++)
    tempBuffer[k] = tempSpace.getData() + bufferSize;

tempBuffer[k] = 0;[/code]

This will compile okay in XCode… however may not compile in Windows (I haven’t checked)… in which case you’ll have to allocate tempBuffer on the heap.

This will only draw the first 2 channels in the thumbnail - Ultimately AudioFormatReader::readMaxLevels & AudioThumbnail::getLevels() need to be rewritten to pass a pointer to an array of values instead of the four floats for the left & right channels’ mins & maxes.

Rail