04-22-2003, 09:38 PM
Is there any way to calculate the wave length of a sound going throught the mic in hz? I want to make a guitar tuner. Here's some simple code to use for the mic:
'*UnTested!*
CONST BaseAddr = &H220 'Replace with your base address
CONST CommAddr = BaseAddr + &HC
CONST DataAddr = BaseAddr + &HA
CONST XMax = 320
DIM Byte(XMax) AS INTEGER
SCREEN 13:CLS
DO
FOR i% = 0 to XMax-1
PRESET(i%, Byte(i%))
OUT CommAddr, &H20
Byte(i%) = INP(DataAddr)
PSET(i%, Byte(i%))
NEXT i%
LOOP
This should display a wave pattern on the screen when using your mic. The x origin seems to be between y pixel 110 and 112. There also seems to be three distinct wave patterns at every moment. If you took the DO:LOOP off, humed a constant tone, and started the program while humming that tone, it would display 320 samples. If you try this, you'll see what I mean by three seperate waves. I'm not sure why that is. Anyways, I thought about how I would calculate the amount of hz going into the mic, and I couldn't come up with any efficient ways of getting an accurate reading, well, not good enough to tune my guitar that is. Any suggestions?
'*UnTested!*
CONST BaseAddr = &H220 'Replace with your base address
CONST CommAddr = BaseAddr + &HC
CONST DataAddr = BaseAddr + &HA
CONST XMax = 320
DIM Byte(XMax) AS INTEGER
SCREEN 13:CLS
DO
FOR i% = 0 to XMax-1
PRESET(i%, Byte(i%))
OUT CommAddr, &H20
Byte(i%) = INP(DataAddr)
PSET(i%, Byte(i%))
NEXT i%
LOOP
This should display a wave pattern on the screen when using your mic. The x origin seems to be between y pixel 110 and 112. There also seems to be three distinct wave patterns at every moment. If you took the DO:LOOP off, humed a constant tone, and started the program while humming that tone, it would display 320 samples. If you try this, you'll see what I mean by three seperate waves. I'm not sure why that is. Anyways, I thought about how I would calculate the amount of hz going into the mic, and I couldn't come up with any efficient ways of getting an accurate reading, well, not good enough to tune my guitar that is. Any suggestions?
strosmash :
www.geocities.com/juice801980/astro.zip
T.A.N.K :
www.geocities.com/juice801980/tank.zip
(right click, save-as...)
www.geocities.com/juice801980/astro.zip
T.A.N.K :
www.geocities.com/juice801980/tank.zip
(right click, save-as...)