Guitar Tuner

• Question

•

hi,

I´m trying to create software-based guitar tuner.

I´m also trying to use Directsound , but i dont know exactly if there is a any way how to use Directsound to get back from the played sound the current frequency ( I dont mean the average frequency , but the frequency in the moment of every second of playing of the sound ) ..

Do you have any idea ?

thanks

Sunday, April 6, 2008 8:27 PM

All replies

• For starters, you would still get the average frequency, you would just get it in smaller increments of sound (say 1/10 second) and return it over and over again.

A sound frequency is a time-dependent property, and so your sample to determine your frequency must be a sample over time.

If you can get average frequency, you can get the frequency for uses.

Sunday, April 6, 2008 8:33 PM
•  David M Morton wrote:
 For starters, you would still get the average frequency, you would just get it in smaller increments of sound (say 1/10 second) and return it over and over again.    A sound frequency is a time-dependent property, and so your sample to determine your frequency must be a sample over time.   If you can get average frequency, you can get the frequency for uses.

i can get the average frequency of the whole track by using this :

Code Snippet

int normfreq = buffer.Format.SamplesPerSecond;

string normfreqtext = Convert.ToString(normfreq);

label1.Text = normfreqtext;

but this is the average frequency of the whole song , no matter what time i click on button with this function .

Can you please explain to me how to use this to get the current frequency of the playing track ?

IMHO its impossible this way , but if you now a way I´d be very glad to hear about it

Monday, April 7, 2008 3:17 PM
• Of what type is "buffer"?

Monday, April 7, 2008 3:19 PM
•  David M Morton wrote:
 Of what type is "buffer"?

It´s SecondaryBuffer

Monday, April 7, 2008 4:12 PM
• If you know the bytes per second of your sound file, you could use the Read method of the Buffer subclass, then instantiate a new Buffer class based on the stream read using the Read method, and calling the   I think that would work, although that would require instantiating several buffer classes over and over again.

Monday, April 7, 2008 4:22 PM
•  David M Morton wrote:
 If you know the bytes per second of your sound file, you could use the Read method of the Buffer subclass, then instantiate a new Buffer class based on the stream read using the Read method, and calling the   I think that would work, although that would require instantiating several buffer classes over and over again.

that´s maybe the problem , i know only the "average bytes per second" and its the same number as average frequency (it may be coincidence ,but I think it´s not )

I uploaded a program I created using the DirectSound , here you can see all possible info i´m able to get via Directsound´s commands :

and heres also the whole project to this program so you can see what the code is :

Monday, April 7, 2008 7:38 PM
• Hi ondra2,

I am sorry that I am not familiar with the DirectX programming, as I understand, play guitar is just plays sounds, and here are some articles which about audio player programming.

http://www.codeproject.com/KB/audio-video/cswavrec.aspx

http://www.codeproject.com/KB/audio-video/cswavplay.aspx

For DirectX programming, you can post your question to the following forums.

http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=99&SiteID=1

http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=323&SiteID=1

Regards,

Xun

Thursday, April 10, 2008 6:31 AM