Author Topic: Recording Audio in QB64?!?!  (Read 5906 times)

0 Members and 1 Guest are viewing this topic.

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Recording Audio in QB64?!?!
« on: September 26, 2020, 09:59:28 pm »
Well,well,well.... I found out that you can record audio in QB64 with one of the WinAPI functions from WINMM.DLL....
I'm not sure if someone already had a way to record audio in QB64 but I couldn't find anything in the forum.

I posted it in my API collection. Here are two recordings I made in QB64:
  [ You are not allowed to view this attachment ]    [ You are not allowed to view this attachment ]  
Shuwatch!

FellippeHeitor

  • Guest
Re: Recording Audio in QB64?!?!
« Reply #1 on: September 26, 2020, 10:57:34 pm »
"This is meeee, singing into the microphone" %uD83C%uDFA4%uD83C%uDFB5%uD83C%uDFB6

I think someone ventured into audio recording via mci strings back in .net. Thanks for bringing the topic back up.

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Recording Audio in QB64?!?!
« Reply #2 on: September 26, 2020, 11:02:35 pm »
%uD83C%uDFA4%uD83C%uDFB5%uD83C%uDFB6
What is that?
Shuwatch!

FellippeHeitor

  • Guest
Re: Recording Audio in QB64?!?!
« Reply #3 on: September 26, 2020, 11:10:50 pm »
Damn, they were emoji. 🎵

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Recording Audio in QB64?!?!
« Reply #4 on: September 26, 2020, 11:20:47 pm »
FreeBASIC had a way to accomplish this. I remember the brief time I used FB, and made one recording while learning the language: swearwords.wav

Hey, pretty cool, Zach! I got by on javascript and html. Just change the path to wherever you keep your QB64 files, and, of course, the recording.wav needs to be in that folder. Just save the code below as whatever.html, in your QB64 folder, click it, and it will appear in your default browser. Click the play button to hear Zach's recording.

Code: Text: [Select]
  1. <!Doctype html>
  2. <html>
  3.   <head>
  4.     <title>Audio</title>
  5.   </head>
  6.   <body>
  7.     <div style="margin:200px auto; text-align:center; font-weight:bold; font-size:24px;">
  8.     <script>
  9.       function play() {
  10.         var audio = document.getElementById("audio");
  11.         audio.play();
  12.       }
  13.     </script><div style="display:inline;">Pete is your SCREEN 0 Hero!</div>
  14.     <input style="font-size:24px;" type="button" value="PLAY" onclick="play()">
  15.     <audio id="audio" src="file:///C:\qb64\recording.wav"></audio>
  16.     </div>
  17.   </body>
  18. </html>

Pete

Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Recording Audio in QB64?!?!
« Reply #5 on: September 26, 2020, 11:38:33 pm »
Shuwatch!

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Recording Audio in QB64?!?!
« Reply #6 on: September 26, 2020, 11:51:39 pm »
Hey, pretty cool, Zach! I got by on javascript and html. Just change the path to wherever you keep your QB64 files, and, of course, the recording.wav needs to be in that folder. Just save the code below as whatever.html, in your QB64 folder, click it, and it will appear in your default browser. Click the play button to hear Zach's recording.

Hey, @Pete
I wasn't able to make it play in my browser. I'm not sure what's going on :( Maybe it's a browser issue.
Shuwatch!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Recording Audio in QB64?!?!
« Reply #7 on: September 27, 2020, 12:11:37 am »
Did you remember to change the line: src="file:///C:\qb64\recording.wav" to whatever folder path your recording.wav is in? If so, what browser? I'm using Firefox. I'll test Opera and Edge, now...

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Recording Audio in QB64?!?!
« Reply #8 on: September 27, 2020, 12:27:29 am »
Did you remember to change the line: src="file:///C:\qb64\recording.wav" to whatever folder path your recording.wav is in? If so, what browser? I'm using Firefox. I'll test Opera and Edge, now...

Yes, that was the first thing I did when I copied your snippet. I am using Edge Dev which is based on Chromium. I'll try it in Legacy Edge next or Chrome and see what happens.
Shuwatch!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Recording Audio in QB64?!?!
« Reply #9 on: September 27, 2020, 12:36:40 am »
64-bit Windows 10. Firefox, Opera, and Edge all worked. I don't have Chrome.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Recording Audio in QB64?!?!
« Reply #10 on: September 27, 2020, 12:39:49 am »
Ah, of course it was something extremely simple. A space in my directory path. It needed to be substituted with %20, of course. Made it work right away. Neato.
Shuwatch!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Recording Audio in QB64?!?!
« Reply #11 on: September 27, 2020, 12:59:19 am »
Good. I agree, just a small problem. If it were a big one, you'd have to try %90 :D

Hey thanks for adding the sound API. Nice collection. I don't know if you have a windows persistency API, but you are welcome to test and add mine to the mix. https://www.qb64.org/forum/index.php?topic=1365.msg105588#msg105588

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Recording Audio in QB64?!?!
« Reply #12 on: September 27, 2020, 01:03:55 am »
Hey thanks for adding the sound API. Nice collection. I don't know if you have a windows persistency API, but you are welcome to test and add mine to the mix. https://www.qb64.org/forum/index.php?topic=1365.msg105588#msg105588

That's pretty neat that it is able to stay topmost! That's nice, especially in Windows 10 where I seem to constantly have an issue where sometimes the window goes to the background when my mouse moves away from it. I'll add it to my collection and credit you.
Shuwatch!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Recording Audio in QB64?!?!
« Reply #13 on: September 27, 2020, 01:15:34 am »
Please be sure to give a shout out to visionmercer, too. I got it working almost fully, except it would only work once. visionmercer pointed me to the SetWindowPos function, which I fiddle with a bit and got it to do the trick. I love that about forums; an abundance of resources and knowledge.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Recording Audio in QB64?!?!
« Reply #14 on: September 27, 2020, 01:17:15 am »
Please be sure to give a shout out to visionmercer, too. I got it working almost fully, except it would only work once. visionmercer pointed me to the SetWindowPos function, which I fiddle with a bit and got it to do the trick.

Done. Right now I'm adding another bit of functionality to the sound API by allowing it to show a waveform using ffmpeg :)

  [ You are not allowed to view this attachment ]  
« Last Edit: September 27, 2020, 01:19:59 am by SpriggsySpriggs »
Shuwatch!