Author Topic: HOW do i sample (not play) audio?  (Read 8397 times)

0 Members and 1 Guest are viewing this topic.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: HOW do i sample (not play) audio?
« Reply #15 on: April 22, 2020, 12:30:52 pm »
Just - small repair, for playing it with _SNDRAW:

FOR I& = 0 TO NumSamples& STEP 2
    _SNDRAW Sample(I&) / 65535, Sample(I&) / 65535
NEXT

so it play correctly (record is stereo?)

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: HOW do i sample (not play) audio?
« Reply #16 on: April 22, 2020, 12:34:16 pm »
Yeah recording is in stereo if i remember,

FOR I& = 0 TO NumSamples& STEP 2
    _SNDRAW Sample(I&) / 65535, Sample(I&) / 65535
NEXT

that would play the same sample through left and right, youd need to +/- either left or right by one.

Unseen


Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: HOW do i sample (not play) audio?
« Reply #17 on: April 22, 2020, 12:36:40 pm »
I am reading your manual - is possible using this library also for converting WAV sounds to OGG? If it can save RAW audio as ogg, is this possible?

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: HOW do i sample (not play) audio?
« Reply #18 on: April 22, 2020, 12:38:38 pm »
Yeah you should be able to save any audio you can load into the buffer into any of those formats.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: HOW do i sample (not play) audio?
« Reply #19 on: April 22, 2020, 12:41:13 pm »
So that's absolutely brilliant!. Great! Thank you very much!

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: HOW do i sample (not play) audio?
« Reply #20 on: April 22, 2020, 12:44:16 pm »
Quote
So that's absolutely brilliant!. Great! Thank you very much!

No problems, happy to be of help. If you need anything else or come into problems just make a post and ill do my best until then, happy coding!

Unseen

Offline MB

  • Newbie
  • Posts: 7
    • View Profile
Re: HOW do i sample (not play) audio?
« Reply #21 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

Offline Parkland

  • Newbie
  • Posts: 51
    • View Profile
Re: HOW do i sample (not play) audio?
« Reply #22 on: April 27, 2020, 08:26:10 pm »
  [ You are not allowed to view this attachment ]  

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: HOW do i sample (not play) audio?
« Reply #23 on: April 28, 2020, 04:23:47 am »
if the sfml files are in

qb64\sfml\

and the wrapper is in your QB64 directory then this shouldnt happen. I can only surmise that youve not got the files or you've not got them in the correct place. The files are available from a previous post on this thread.

Unseen


Offline Parkland

  • Newbie
  • Posts: 51
    • View Profile
Re: HOW do i sample (not play) audio?
« Reply #24 on: April 28, 2020, 05:56:39 pm »
The sfml folder is in the qb64 folder, with it's contents.
The rest of the files in the zip file are in the QB64 folder.


Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: HOW do i sample (not play) audio?
« Reply #25 on: April 28, 2020, 06:05:48 pm »
Then i dont know whats wrong my man, what O/S are you running?

Offline Parkland

  • Newbie
  • Posts: 51
    • View Profile
Re: HOW do i sample (not play) audio?
« Reply #26 on: April 28, 2020, 06:15:14 pm »
linux mint.
going to try maybe older version of qb64 than .954

Offline Parkland

  • Newbie
  • Posts: 51
    • View Profile
Re: HOW do i sample (not play) audio?
« Reply #27 on: April 28, 2020, 06:44:42 pm »
windows with 0.954 doesn't have the same problem as linux with version 0.954

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: HOW do i sample (not play) audio?
« Reply #28 on: April 28, 2020, 07:01:48 pm »
You probaly need the linux version of the library...i use my old XP laptop for QB64

https://www.sfml-dev.org/download/sfml/1.6/

Hope that helps

Unseen

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: HOW do i sample (not play) audio?
« Reply #29 on: April 28, 2020, 07:20:14 pm »
You probaly need the linux version of the library...i use my old XP laptop for QB64

https://www.sfml-dev.org/download/sfml/1.6/

Hope that helps

Unseen

Or try running it under WINE.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!