From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: Date: Sat, 15 Jan 2011 13:05:28 +0100 Message-ID: From: Gorka Guardiola To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [9fans] sound, graphics, tuner Topicbox-Message-UUID: 997ce340-ead6-11e9-9d60-3106f5b1d025 On Sat, Jan 15, 2011 at 11:38 AM, wrote: >> Can anybody comment this and/or possibly point me at some good documents= ? > > It looks kind of easy, although I've never gone there myself. =A0After > all, you just need to display two lines, one fixed (you omitted to > mention that you need to specify the tone you are after) and one that > moves closer or further from the base line as the tuning is adjusted. > Two points may suffice, but they may be hard to read. Aliasing... You need to read more than two points, even if you produce only two after. Essentially I would do something like: Read N PCM samples from the sound card, this is just a read from the audio in file, easy part. The samples you can read from http://plan9.bell-labs.com/magic/man2html/3/a= udio audio(3) or a similar interfaces provided by usb/audio usb(4). Calculate some sort of windowed FFT. Find the peak (I would correlate with a moving peak shape and find a big va= lue). Generate the read/estimated frequency, fin. Then you can draw the margin for the frequency error you tolerate which are probably two lines fthlow, fthhigh or different colors dividing the window/output in three parts, too high, too low and acceptable and superpose the line depicting fin over it (something like the letonian flag). fthlow and fthhigh can come from the user clicking on the window and moving up and down or from some slider (I would do the first).. This last part, I would use draw http://plan9.bell-labs.com/magic/man2html/2/draw draw(2). You can use control http://plan9.bell-labs.com/magic/man2html/2/control control(2) to add sliders but for what you are doing just drawing rectangles and lines should be fine. HTH. G.