AudioThumbnail Bug, or just User Error :)


#1

I’m not entirely sure what I’m doing wrong. I’ve written similar code that works fine in OS X, but my component shows this y offset error under windows. Below is the .cpp code for my component. I can provide the .h code upon request.

As a side note (don’t know if this matters) but I’m resizing the component in my MainComponent after I new up the instance of AudioThumbnailComponent.

[code]#include “AudioThumbnailComponent.h”

//[MiscUserDefs] You can add your own user definitions and misc code here…
//[/MiscUserDefs]

//==============================================================================
AudioThumbnailComponent::AudioThumbnailComponent (int numSamples, AudioFormatManager & mgr, AudioThumbnailCache & cache)
: groupComponent (0),
mpThumbnail (0)
{
addAndMakeVisible (groupComponent = new GroupComponent (T(“new group”),
T(“Audio”)));

mpThumbnail = new AudioThumbnail (numSamples, mgr, cache);

//[UserPreSize]
mpThumbnail->addChangeListener(this);
//[/UserPreSize]

setSize (400, 150);

//[Constructor] You can add your own custom stuff here..
//[/Constructor]

}

AudioThumbnailComponent::~AudioThumbnailComponent()
{
//[Destructor_pre]. You can add your own custom destruction code here…
//[/Destructor_pre]

deleteAndZero (groupComponent);
deleteAndZero (mpThumbnail);

//[Destructor]. You can add your own custom destruction code here..
//[/Destructor]

}

//==============================================================================
void AudioThumbnailComponent::paint (Graphics& g)
{
//[UserPrePaint] Add your own custom painting code here…
//[/UserPrePaint]

//g.fillAll (Colours::white);

//[UserPaint] Add your own custom painting code here..
mpThumbnail->drawChannel(
	g,
	(8) + 16, (0) + 24, getWidth() - 44, (getHeight() - 8) - 39,
	0, mpThumbnail->getTotalLength(),
	0,
	1);
//[/UserPaint]

}

void AudioThumbnailComponent::resized()
{
groupComponent->setBounds (8, 0, getWidth() - 14, getHeight() - 8);
//mpThumbnail->setBounds ((8) + 16, (0) + 24, getWidth() - 44, (getHeight() - 8) - 39);
//[UserResized] Add your own custom resize handling here…
//[/UserResized]
}

//[MiscUserCode] You can add your own definitions of your custom methods or any other code here…
void AudioThumbnailComponent::addChangeListener(ChangeListener* const listener) throw()
{
mpThumbnail->addChangeListener(listener);
}
//[/MiscUserCode]
[/code]


#2

You may also have a problem in your x-axis as well. Do you really have that much silence at the beginning and end as well as the clipped group of samples at the beginning and end of the non-zero data?

The reason I mention the x-axis is that I had a similiar problem: whenever I set the x argument to drawChannel to any value except zero, AudioThumbnail drew a line followed by random garbage, until it got to x, at which it draws correctly. I thought I had reported this in an earlier post, but apparently I forgot after I found a workaround. The workaround was to set the x argument to zero and adjust my component to compensate. The component is a little thin on the left side, but it doesn’t look too bad.

Update: I’ve posted the above and another anomaly I found as possible bugs.