 |
|
|
04-25-2011, 02:42 PM
|
#1
|
Human being with feelings
Join Date: Sep 2008
Location: Sweden
Posts: 7,029
|
JS Meters tuner, how does it work...?
Just curious, how the heck does it work...? The code:
Code:
// This effect Copyright (C) 2004 and later Cockos Incorporated
// License: GPL - http://www.gnu.org/licenses/gpl.html
// this algorithm is based on the one used by gtkguituner, the schmitt-triggering.
desc: schmitt-triggering tuner
slider1:0.5<0.001,0.990>trigger factor
slider2:1024<128,16384>numsamples
slider4:0,octaves from a110
slider5:0<0,12,1{-,A,A#,B,C,C#,D,D#,E,F,F#,G,G#}>note
slider6:0<0,10,1{-,[*----|-----],[-*---|-----],[--*--|-----],[---*-|-----],[----*|-----],[-----*-----],[-----|*----],[-----|-*---],[-----|--*--],[-----|---*-],[-----|----*]}>tune
slider7:0,freq (Hz)
@init
volthresh=2^(-60/6);
@slider
state=0;
splpos=0;
trigfact=slider1;
numsamples=slider2;
ufreq = (srate/numsamples)/3;
freqcnt=0;
@sample
state ?
(
// track minimum and maximum values for sample
a1=max(a1,spl0);
a2=min(a2,spl0);
splpos[0]=spl0;
maxvol = max(maxvol,spl0);
splpos += 1;
splpos >= numsamples ?
(
splpos=0;
state=0;
a2 *= trigfact;
a1 *= trigfact;
lst=0;
startp=1;
loop(numsamples-1,
lst == 0 && startp[0] > a1 ? lst=1;
lst == 1 && startp[0] >= a2 && startp[1] < a2 ? lst=2;
lst != 2 ? startp+=1;
);
smtrig=0;
endp=startp+1;
tc=0;
i=startp;
loop(numsamples-startp,
smtrig ?
(
i[0] >= a2 && i[1] < a2 ? (
endp=i;
tc+=1;
smtrig=0;
)
)
:
(
smtrig = i[0] >= a1;
);
i+=1;
);
endp == startp ? endp += 1;
s = srate * tc / (endp-startp);
s > 4 ? slider7=s;
(freqcnt += 1) >= ufreq ? (
freqcnt=0;
oofs=log(slider7/110)/log(2);
slider4=oofs|0;
slider5=(oofs*12)%12;
slider6=((oofs*12)*100)%100;
slider6 >= 50 ? ( slider5 += 1; slider6 -= 100; );
oofs < 0 ? ( slider5 = 12-slider5; slider4-=1;);
slider5 >= 12 ? (slider5-=12; slider4+=1; );
maxvol >= volthresh ? (
abs(slider6)>=25 ? slider6=sign(slider6)*50 : slider6*=2;
slider6 += 50; slider6/=10; // 0-10 for funny lookin meter
slider6=max(min(slider6+1,10),0);
slider5+=1;
) : slider5=slider6=0;
);
sliderchange(8+16+32+64);
maxvol =0;
);
)
:
(
0[0] <= 0 && spl0 > 0 ?
(
state=1;
1[0]=spl0;
splpos=2;
a1=spl0;
a2=0[0];
);
);
Not an FFT in sight, yet it manages to detect the frequency of the input. And I don't get it... how does it do that?
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
|
|
|
04-25-2011, 02:54 PM
|
#2
|
Human being with feelings
Join Date: Mar 2010
Posts: 4,713
|
It says it at the top of the file: it uses a Schmitt-trigger  It seems to be a variation of zero-crossing detection in order to estimate the period of a waveform.
|
|
|
04-25-2011, 03:18 PM
|
#3
|
Human being with feelings
Join Date: Apr 2008
Location: Saarlänner
Posts: 1,141
|
From here:
Quote:
Description:
Guitune is a linux program for tuning guitars and other instruments by using the method of Schmitt-triggering, i.e. counting the number of triggerings between two trigger levels in a certain amount of time. Why not use FFT like many other tuning devices? Well because other tuning devices are not as fast as mine !!
With FFT you need many samples to archieve the accuracy needed for tuning instruments. You often get times of around 1 second between two measurements and the computer is quite busy in this second calculating the FFT. Using Schmitt-triggering you get a measurement every 10th of a second or even less (depending on the sample frequency you use). Most of the time the computer only waits for the samples.
The Trigger levels are adjustable. For a pure sine-wave the trigger levels could be zero. But for a wave wth overtones like the one in the figure above you need a non-zero triggerlevel. It is preadjusted to a level of 60% of the current maximum which should be able to deal with most instruments.
|
hth
Blechi
|
|
|
04-25-2011, 03:29 PM
|
#4
|
Human being with feelings
Join Date: May 2009
Posts: 1,265
|
It basically uses http://en.wikipedia.org/wiki/Schmitt_trigger to determine the min and max of a cycle of the waveform, and on the basis of this calculate the cycle length.
E.g. simple zerocrossing on the following waveform would yield wrong results.
Code:
x
x x x
x x x
x x x x
-O------------------O-O-O----------------O------- = 5 crossings
x x x x
x x
x x
x x x
x
|-----------------|-|---|--------------|
1/2 cycle 1/2 cycle 1/2 cyle
1/2 cycle <--- whats the full cycle length?
Simply tracking the max and min can yield the following problem:
Code:
Is A the max since the signal is decreasing again after it,
and is B then the min since the signal is increasing after it again?
x
A x x
x B x
x x x x
-x------------------x-x-x----------------x-------
x x x x
x x
x x
x x x
x
|--|
1/2 cycle WTF?
Tracking the max and min with Schmitt trigger yields:
Code:
Make A temp max.
B isn't below hysteresis so we still track the max.
C also above hyst ... etc ... so O is the highest value
above hyst so we make it max.
Same for the minimum.
O <---- MAX
A x x
.....x...B.......x............................... Hysteresis
x x x x
-x------------------x-x-x----------------x------- = 5 crossings
x x x x
..........................x............x.......... Hysterisis
x x
x x x
O <------ MIN
|--------------------|
1/2 Cyclelength
Anyway hope this helps to illustrate the algorithm.
|
|
|
04-26-2011, 12:57 AM
|
#5
|
Human being with feelings
Join Date: Sep 2008
Location: Sweden
Posts: 7,029
|
Excellent, people... Thanks very much, all of you.
Those illustrations are super, Mich.
Simply gotta love this forum...
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
|
|
|
09-09-2012, 11:16 PM
|
#6
|
Human being with feelings
Join Date: Mar 2012
Posts: 1,824
|
Can this be used to make a Tuner to tune individual strings?
Example 6 string electric
I want the high E to be a D
Could this be possible?
|
|
|
09-10-2012, 08:29 AM
|
#7
|
Human being with feelings
Join Date: Sep 2008
Location: Sweden
Posts: 7,029
|
Quote:
Originally Posted by danfuerth
Can this be used to make a Tuner to tune individual strings?
Example 6 string electric
I want the high E to be a D
Could this be possible?
|
I use ReaTune to tune my guitar, if that's what you mean.
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
|
|
|
09-10-2012, 10:43 AM
|
#8
|
Human being with feelings
Join Date: Mar 2012
Posts: 1,824
|
well not to tune mind you. I am trying to come up with a handy way to tune your guitar to a specific tunning Dropped D, open E, Open A. without tunning your strings mind you. There is recent activity in the hardware market for the first Autotune guitar processors, this is a day that everyone has been waiting for AUTOTUNE for guitar.
However what I am trying to is different . I know reatune can also do some pitch manipulation.
But having the ability to do to A open, E open, Dropped D, without messing with the guitar would be incredibly important.
|
|
|
09-10-2012, 12:19 PM
|
#9
|
Human being with feelings
Join Date: Sep 2008
Location: Sweden
Posts: 7,029
|
Quote:
Originally Posted by danfuerth
But having the ability to do to A open, E open, Dropped D, without messing with the guitar would be incredibly important.
|
I see. But this JS script is certainly not the way to do it. ReaTune is much better at manipulating pitch.
In HW I can imagine how it could be done. A six channel output guitar which outputs each string on its own channel. Then you just record each output on its own track, and tune to your hearts content afterwards. Doesn't seem that difficult, actually.
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
|
|
|
09-10-2012, 03:43 PM
|
#10
|
Human being with feelings
Join Date: Jun 2010
Location: Somewhere PRO
Posts: 1,049
|
dan .... im pretty sure you will need a MIDI guitar system ala Roland GK55/GK3 or whatever, if you want play in standard but sound in Drop D.
Yesterday i tried the Morpheus DropTune, as the act i play in has a few tunings (Standard, Eb, D, DADGAD, Open E ...no drop tunings though) and im sick of lugging 6-10 guitars to shows, even small shows.
Anyway i can safely say that this didnt work for me.
Latency on low notes, a weird harmonizing sound on some high notes.
Heaven help me once that goes through FOH
I work at a rather large Gibson dealer so i also have lots of experience with the Gibson Robots ... and i can safely say that that isnt the solutiuon either.
In short, HARDWARE cannot do this correctly yet, let alone software.
|
|
|
09-10-2012, 09:57 PM
|
#11
|
Human being with feelings
Join Date: Mar 2012
Posts: 1,824
|
crap LOL. Maybe sometime in the future hehehe Thanks for looking up at that for me
Oh well we can only dream for now...
|
|
|
03-06-2019, 06:00 AM
|
#12
|
Human being with feelings
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 3,767
|
|
|
|
07-30-2019, 05:55 AM
|
#13
|
Human being with feelings
Join Date: Mar 2013
Posts: 445
|
@Tone its funny you mention that JSFX, i was just trying it out as a realtime tuner for live guitars and bass, the issue I have is its too CPU hungry on record armed tracks (1 instance adds around 4ms RT block size, which at my buffer size of 64 samples is way too long)
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 04:03 AM.
|