Seek bar for audio


#1

Afternoon all

I have a file player and have a slider that sets the position in the track to start playing from.
I can’t work out how to make it more accurate!!! At the moment I have minValue set at 0 and maxValue set at 360??? I am assuming this has reference to angles?

The idea was set the slider so at the start it is at the start of the track and at the end it is at the end of the track.

so,… What i have is

if(sliderThatWasMoved == positionSlider)
{
	masterPosition = (positionSlider->getValue() / 360);

// to set it beteween 0 and 1,
masterPosition = (sampleLength * masterPosition);
// to set it at the position in “samples” i would like it to be at,
//std::cout << masterPosition << “\n”;
transportSource.setPosition(masterPosition);
// sets the position in the file to be playing from.
}

This doesn’t work at all. as soon as you move the slider it stops!
question is why :slight_smile: I can’t work it out for the life of me

Cheers

Chewy


#2

sliders don’t calculate anything in angles, you can easily set a minimum value to 0.0 and a max to 1.0 with a step of 0.01 (or less) for easier calcuclations.


#3

Sorted it lol

I was passing it the length in samples.
I have divided the sample length by the sample rate and passed that as my maximum value, works ever so well now :slight_smile:

Thanks for the tip :slight_smile: