Different audio output when playing same file in flac vs wav

Hi,

I am writing a vsti sampler plugin

I started with the vst plugin demo and added a Synth class together with samplersounds and samplervoices.

I am getting very different audio output out of the speakers if I play the exact same 24 bit, 48KHZ file in wav vs flac format. I make sure the ASIO driver is set to 48KHZ and the synth also is set to 48KHZ. I use vstHost to test the plugin.

I am very familiar with the samples and I make my comparision against the “normal” sound that I hear if I play with play.exe from sox on Windows Vista both in wav and flac format. It sounds the way it should and both wav and flac sound identical.

When I use Flac in Juce, the sound is very bandwidth limited. Almost like all the highs were filtered out. If I use a wav version of the same file in Juce, it sounds very close to the original played with sox in terms of frequency but there seems to be an enveloppe added to the sample that makes it decay faster. Note that for test purposes I even removed all attack and decay treatment in samplervoice.rendernextblock and the result is the same.

I use this code:

ARSynth->addVoice(new SamplerVoice());
ARSynth->setCurrentPlaybackSampleRate(48000.0);
FlacAudioFormat flacFormat;
AudioFormatReader* audioReader=NULL;

int i;
for (i = 0; i < 64; ++i) samplerNotes.setBit (i);

 audioReader = flacFormat.createReaderFor(F.createInputStream(),false);
if (audioReader!=NULL) {

ARSynth->addSound (new SamplerSound (T("demo sound"),
                                      *audioReader,
                                      samplerNotes,
									  0,   // root midi note zero based
                                      0.0,  // attack time
                                      0.0,  // release time
                                      25.0  // maximum sample length
                                      ));
}

delete audioReader;

Is there a reason I get such different audio playback for the same data played with Juce in wav or flac format?

Thank You

Patrick Robin

No idea! The flac wrapper just takes the output from the flac library and serves it up… there’s nothing that I can think of which would be any different to any other format. Have you stepped through the rendering pipeline in the debugger to watch exactly what happens to the audio on its way to the outputs? Maybe a resampling stage has found its way in there somehow.

It seems the flac data read is not what it should be when using FlacAudioFormat reader. I did a test where the plugin loads two identical files, one wav the other Flac. Then, I run :

audioReader->readMaxLevels (0, 960000,lowestLeft,highestLeft,lowestRight,highestRight);

On both of them. The wav file gives me .69 for the max on the right channel, as expected. The flac reader gives me .03 on the right channel.

As I said previously, the two files contain the same data except for the format and they play identically using sox player on Vista

I will dig into the Juce flac reader to see what can cause this.

PR

I’ll be interested to see what you find…

The first obvious thing that could cause the problem is that Juce incorporates Flac 1.1.3. I use Flac 1.2.1 . I am aware of some incompatibilities between the two.

Will try to make it use 1.2.1

PR

The tip of juce does use v1.2.1

Thanks,

I downloaded the tip and now the wav and flac sound identical on Juce but there is still a difference vs the same file played using sox.

Played wiht the Juce plugin, some details/nuaces are missing. It seems to decay faster (even if I comment out all attack/decay code in samplevoice). The test sound is a 23 seconds cymbal crash sample. I cannot tell what precisely what filtering could cause the difference I hear.

I assume the difference could be in the way vstHost plays audio. I have no other plugin/processing loaded in my vstHost.

Is it common to notice such differences when playing samples via a vstHost compared to a straight player such as sox?

Thank You

Patrick Robin

What’s vstHost? I’ve never actually heard of it. Obviously a host could be doing any number of things to the audio before you hear it.

Most likely something is resampling it along the way. Could be within juce, depending on how you’re playing the file, or could be the host, or could even be the audio drivers.

[quote=“jules”]What’s vstHost? I’ve never actually heard of it. Obviously a host could be doing any number of things to the audio before you hear it.

Most likely something is resampling it along the way. Could be within juce, depending on how you’re playing the file, or could be the host, or could even be the audio drivers.[/quote]

vstHost is a small free vst host : http://www.hermannseib.com/english/vsthost.htm

I am trying to use Juce pluginHost

Is it possible to actually produce sound output? I add my sampler plugin to the graph and connect the midi input to it but I am not sure if I need to connect my plugin’s audio outputs to something to get sound. What is the role of “Audio input” and “Audio output”, the later doesn’t have any connections.

Thank You

Patrick Robin

Well yes, of course it’s supposed to produce audio out! But TBH I’ve been tinkering with it lately and may have broken something… Maybe grab the version from v1.45 and try that?