SoundCard LineInput

Just starting out? Need help? Post your questions and find answers here.
GL
New User
New User
Posts: 8
Joined: Thu Dec 18, 2003 2:05 pm
Location: Netherlands

SoundCard LineInput

Post by GL »

Hello forum,
I am busy to make a "virtual" audio mixer with a touchscreen.
The visual part and analog interface is working.
But my Vu levels are only actif when I use streaming audio.
(wav files and CDDA)
My question is can I use the soundcard line input for monitoring
(Vu levels) of a external audio source.
It would be great to do it with FSOUND or else an other way.
I am a PB beginner so any info is welcom.

Thanks in advance,
Ger.

In love with PB!!!
Registered PureBasic user
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

Post by Froggerprogger »

For use with fmod see the record-PB-example from the PB-fmod-package of KarlKoX:
http://starnetasso.free.fr/Upload/fmodapi371win32.zip

You would have to realize it by filling a playback-buffer with the already recorded data and play it in this way, that it is always near behind the recordloop. So do fullduplex-recording/playback and get the VULevels from the playback.
%1>>1+1*1/1-1!1|1&1<<$1=1
GL
New User
New User
Posts: 8
Joined: Thu Dec 18, 2003 2:05 pm
Location: Netherlands

Post by GL »

Thanks Froggerprogger !

I give it a try. :D

Ger
Registered PureBasic user
GL
New User
New User
Posts: 8
Joined: Thu Dec 18, 2003 2:05 pm
Location: Netherlands

Post by GL »

Hi Froggerprogger,

Compiling the record-PB-example from the PB-fmod-package of KarlKoX
I get the error:
.....api/PureBasic/fmod_proc.pbi
Line 9: Invalid name: same as an external command.

What could that be?

Ger
Registered PureBasic user
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

Post by Froggerprogger »

That means (for 99%), you use the PB-import for fmod atm, so you have the pb-fmod-include-file inside your userlib-directory to get direct access to fmod's functions through this lib.
Another possibility to use fmod is to use an include-file that wrapps all fmod-functions. (slower)
These functions have the same name, as the include-functions, so you have 2 possibilities:
1. comment out this Include-line, and hope it will work anyway (actually it should, the only really recognizeable change to fmod 3.7* was one required extra-parameter in Stream_Open.
2. copy away the FMOD_DLL_IMPORT-file from your userlibs-directory.

btw:
In some days (really not more) the fmod-import for 3.71 will be published.
Including a lib for all the functions and a resident for all the constants.
%1>>1+1*1/1-1!1|1&1<<$1=1
GL
New User
New User
Posts: 8
Joined: Thu Dec 18, 2003 2:05 pm
Location: Netherlands

Post by GL »

Hi Froggerprogger,

2. copy away the FMOD_DLL_IMPORT-file from your userlibs-directory.

Fix the problem.

Thanks!

Ger
Registered PureBasic user
chio
User
User
Posts: 30
Joined: Thu Jun 24, 2004 1:55 pm
Location: New York City
Contact:

note frequency

Post by chio »

Any ideas on how I can display the note frequency Hz using the record script or such?

I want to be able to play a note and see what note it is on screen.

Thanks,
chio
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

Post by Froggerprogger »

@chio

1.
You could use fmod's FFT on the Line-Input by full-duplex-recording/playing in the same way as in the record-example. You just have to activate the FFT on the output. If you don't want to listen to the sound you could write a DSP-callback at point > 900 in DSP-queue that resets the playback-buffer to 0.

2.
It 'sounds' that you want to play a note on any (?) instrument and find out "it's frequency".
The problem is, that all sounds that are not pure sinus are the sum of up to endless many sinus-sounds which means that playing a note on the guitar would result in many frequencies rising up in the spectrum. So you would have to search for the most loud frequency, which should work for pure instruments with clean sounds.

3.
Another (and quite bigger) problem is the accuracy of fmod's FFT. At the moment 1024 samples are used for doing FFT (which is fast, and enough for most purposes), that results in a linear accurance of ~43 Hz. (1024 samples at 44100Hz results in 44100/1024 = 43,06640625 Hz.) => Each of the 512 Values of the resulting array contains the loudness of the frequency 43*id + 1
So the higher the frequency the more accurate the spectrum is:
e.g. you have in range of one octave from 4000 Hz - 8000 Hz about 93 vaules, but in range from one octave from 440 Hz - 880 Hz just about 10. So you do not have just one value for one half-tone in that (often used) octave.

=> You have to write your own FFT which uses more samples
(e.g. 32768, so you would have 16384 values with a difference of ~1,3 Hz.) But of course you would have to wait ~0,7 seconds to see a result.

4.
The standard pitch A has the frequency 440 Hz.
You get each half tone (tempered) over it by multipling this with 12th square of 2,
so Pow(2, 1/12).
So the freqency of a tone x half tones above it would be calculated by

Code: Select all

fq = 440 * Pow(Pow(2, 1/12), x)
For a tone y half tones under it you must use

Code: Select all

fq = 440 / Pow(Pow(2, 1/12), y)
(which is the same as using negative x in the above formula)
%1>>1+1*1/1-1!1|1&1<<$1=1
chio
User
User
Posts: 30
Joined: Thu Jun 24, 2004 1:55 pm
Location: New York City
Contact:

Thanks

Post by chio »

Man that sounds like rocket science :-)

Thanks a lot for the info, I am going to study this well and try to see how I can come up with a good solution.

One of the reasons I was not able to find a way is because I would have imagined that if A = 440 the other notes would have an specific fq which could be read.


Thanks a million
chio
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

Post by Froggerprogger »

...perhaps I misunderstood your answer, but it IS so, that each note has exactly one frequency, which you can calculate by the above formula:

Code: Select all

a = 440 Hz
ais = a * Pow(2, 1/12) = 466,1 Hz
b = ais * Pow(2, 1/12) = 493,9 Hz
c = b * Pow(2, 1/12) = ...
..
..
x = a * Pow(Pow(2, 1/12), diff) = ??? Hz.
(where x is the note lying diff half tones above/under a.)
But this is just for pure sinus-tones. Playing an 'a' on a guitar will affect many frequencies to be heard (which ones is the charakteristic of the instrument) - But when playing an 'a' the 440 Hz should be the loudest frequency in it's spectrum.

So you would have to scan the whole spectrum (e.g. the 512 values, but better more, see above) for the loudest frequency and calculate it's representation as a note.
%1>>1+1*1/1-1!1|1&1<<$1=1
Post Reply