Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - MB

Pages: [1]
1
QB64 Discussion / Re: HOW do i sample (not play) audio?
« on: April 30, 2020, 08:07:29 am »
By chance does anyone have any idea / experience with what method is used to figure out frequencies?
Possibly similar to FFT?

I tried measuring every time the wave crosses 0, but that only works for the loudest frequency.
I tried measuring every peak and valley, but that only works for the smallest frequency.

Wondering what process would normally be employed if you want to know strengths of certain frequencies in the sound.

Crossing zero only works well with a single cycle style of waveform. 

I have been porting over some of my own code that I made in C for one of my "Teensy 4.0" microprocessor into QB64; however, it is far from being ready to share as is it implements the Laplace Transform.

QB64 user "_vince" made a real nice clean sample of a fast algorithm for computing the DFT for N=2^k in QB64. He also list a optimization for real only input FFT in the same thread, take a look at his post in this link:

https://www.qb64.org/forum/index.php?topic=1938.msg111661;topicseen#msg111661

-MB

2
QB64 Discussion / Re: HOW do i sample (not play) audio?
« on: April 29, 2020, 03:01:36 pm »
Parkland,

This is the code I used to see the leading dead space, file "rec2sav.bas" attached.

Code just tells you amount of samples where about the empty buffer ends and the noise floor begins. Then the total samples.


Unseen, I love that you made this wrapper... as I only need to record samples and analyze data, this is a neat tool in my books!

- MB

3
QB64 Discussion / Re: HOW do i sample (not play) audio?
« on: April 29, 2020, 02:20:51 pm »
Parkland,

When I do this code (running under 32-bit windows):

   Mic_Start 22000
   _DELAY 2
   Mic_End

I collect 33673 samples, my first 10515 samples are all zeros. samples 10516 through 44188 have data.

Every time I sample my hardware lags for around 10k samples when using the 22000 sample rate.

Do a simpler test of just running this codet:

   Mic_Start 22000
   _DELAY 5
   Mic_End
   Mic_Save ("test.raw") ' change .raw to a format you use on your platform.

just as a sanity check to see how much lag/(if any) you have before data begins to accumulate.

- MB


4
QB64 Discussion / Re: HOW do i sample (not play) audio?
« on: April 22, 2020, 02:27:19 pm »
Petr,

yep, corrected that and the error went away. I added "_SNDPLAYFILE "Test.wav", 1" to the end of code at the time and it played the audio just fine; just to verify the compiler linked to the library was working.


Unseen Machine,

Thank you so much for the sample code, it is just what I needed. I also downloaded the manual you attached to this thread. For the time being I only need to do a sample & hold of the audio data from a surface contact mic affixed to a test fixture; the samples stored in the array will undergo a Windowed Discrete Fourier Transform to generate a waterfall plot diagram as part of a vibration analysis of AC motors. I also plan to add a comparative pass/fail analysis to the data array to help spot faulty motors. Doing this in QB64 will cut down my devolvement time considerably.
 
When I get to the point where the code works to my task I will post the code here on the QB64 forum for other to play with.

Thank again, I am excited about finally being able to move forward with putting some of my vibration analysis ideas to the test.

- MB

5
QB64 Discussion / Re: HOW do i sample (not play) audio?
« on: April 22, 2020, 11:44:13 am »
The DSL version of QB64 (Version 0.954 Windows) does not give a compile error when using the "SFML_Audio_Wrapper.bas" example. I do get a "Line:21 Subscript out of range" error. So it is making it past that first "Sample(i&) = Sound_Get_Sample%(i&)" code without an error.

DSL QB64 version found at https://www.qb64.org/portal/historical-qb64/

I don't understand how to put this to use for accessing the audio input. I would really love to see example code of how read the audio line input or microphone line.

- MB

6
QB64 Discussion / Re: HOW do i sample (not play) audio?
« on: April 22, 2020, 10:32:29 am »
I gave it a shot in QB64 (Windows 32-bit Version 0.980) & QB64 (Windows 32-bit Version 1.2 Revision 20171230/83). Both attempts gave me the C++ compile error.


QB64 rev 1.2 also had this remark within \\qb64\internal\temp\compilelog.txt

In file included from ..\\temp\\regsf.txt:1:0,
                 from qbx.cpp:1028:
..\\temp\\..\\..\\SFML_Audio_Wrapper.h:7:26: fatal error: SFML/Audio.hpp: No such file or directory
compilation terminated.


Unseen Machine, any chance you recall what was the last QB64 build was that worked with the SFML_16_Wrapper?


I have been trying to get this to work since January... Thought I was simply doing something wrong.

I have considering using the 'Teensy 4' as a proprietary audio capture device that would send the data through to QB64 via a serial port connection for me to further process within QB64. It would really rock if I was able to acquire audio samples directly from with QB64 useing the on hand windows resources.

-MB

7
Please advise what the best method in QB64 (64-bit version) is for capturing audio into an array by use of microphone or line-in.

I noticed evidence that Unseen Machine used the SFML Library with QB64 as a microphone librarie; however, I lack the experience to get SFLM working with the "SF_Mic_Get_Input()" functions myself. Would need to see working example of how to both setup the SFML Library with QB64 and perform the calls.

I recall using Qbasic 7.1 with "OUT &H22C, &H20" to set a SoundBlaster audio card and "INP(&H22E)" to poll the data.

Anyone have any examples they can post or will to draft out an example?

Pages: [1]