Wav's running a bit too slow / out of tune

H
HansEhv posted Nov 19 '15, 00:13:

Hello Joseph and others,
Thanks for these mighty inspiring ideas !

I’m currently working on an implementation to trigger special samples for use in our own band (trigger simple and short fills prepared in advance by ourselves).

However: the samples are running a few notes low (and slow) compared to the original wav’s.
I can get it somewhat right by sending notes about 4 or 5 above the midi number in the filename, but that seems a clumsy workaround to me.

In the samplerbox.py I see “SPEED = numpy.power(2, numpy.arange(0.0, 84.0)/12).astype(numpy.float32)”.
Is that the basis of the speed I need and if so: what is this based on / how should I adapt this to get a proper mapping of the timing towards the hardware.

I’m testing on a B+ model via the internal audio with "standard" 2 channnel 44100 Hz WAV's.
Does the hardware indeed have a relation the parameters above?

Thanks in advance!

H
HansEhv posted Dec 17 '15, 23:36:

Changing to Pi-2 gave same result.
The problem disappeared when using an external soundcard on this Pi-2.
Since that was the objective anyway I've stopped investigation.

R
Renno posted Feb 16, 23:18:

Hi

It is already a very old post, but thanks to it I found the right place to modify the code because my notes were about 40 cents off. I think I was not entirely sure what I exactly did, but I can just describe the workflow:

First of all, in my setup, I am using 48000 Hz.

The first thing which I tried out was the number "12" which I changed to the number "10" it changed the intervals between the numbers, so it was not the right thing. Because the Intervals between the notes were correct, but they were all about 40 cents off as already mentioned so the starting point had to be different, from where the numbers of the speed started.

For this, I changed the number 0.0 to 0.5 which gives the starting point for the first note:

“SPEED = numpy.power(2, numpy.arange(0.5, 84.0)/12).astype(numpy.float32)”.

And got quite a nice result, my C4 was already a D4 or at least close to that. Next, I changed my midi keyboard pitch to -2 halftones.
I could continue to play like that, but I was thinking, that maybe I could eventually get close to perfect results somehow, where I don’t have to make changes externally on a midi keyboard.
So I changed 0.5 to -1.5 which shifted the starting point even further, at the same time I changed 84 to 86 to change the size of matrixes/samples because with the 84 it started to “flatter”(I hope it is a correct term) and I got my C4.

So it looked like this:

“SPEED = numpy.power(2, numpy.arange(-1.5, 86.0)/12).astype(numpy.float32)”.

But as it was still a few cents off, then I changed -1.5 to -1.45; and my final result is:

“SPEED = numpy.power(2, numpy.arange(-1.45, 86.0)/12).astype(numpy.float32)”.

Hopefully, it helps somebody, who feels that their cool “Samplerbox” setup is out of tune. And maybe Joseph or somebody else will find the time to comment on this post.

Thank you.

H
HansEhv posted Feb 18, 22:42:

Hi Renno,
Interesting approach.
I invite you to take a look at my fork at homspace.nl/samplerbox.
The docs have an explanation of 48kHz usage and the image you can download there has some more features, including a USE_48kHz configuration option (actually implemented quite differently).
Regards, Hans

...

  (not published)
  I want to post as guest
 

Post