Posts: 733
Threads: 30
Joined: Apr 2022
Reputation:
43
@Pete
Nah, that wouldn't affect my code at all as my code uses an old DLL that's been around a while. Same DLL I use with my Video player.
Tread on those who tread on you
Posts: 2,171
Threads: 222
Joined: Apr 2022
Reputation:
103
You have to be careful calling old drivers. I ended up in the desert, yesterday, because my 80 year old Uber driver took a wrong turn on the I-5.
Good luck finding it then, it "sounds" cool!
Pete
Shoot first and shoot people who ask questions, later.
Posts: 733
Threads: 30
Joined: Apr 2022
Reputation:
43
I think I found it. It looks like it was on my GitHub. You'd need ffmpeg to show the waveform at the end. Or you could reuse Fellippe's code for showing a sound's waveform.
Code: (Select All) OPTION _EXPLICIT
_TITLE "mciSendString Record Test"
StartRecording
DIM x
DIM y
x = TIMER(0.01)
DO
y = TIMER(0.01)
CLS
PRINT "Recording...Press any key to stop"
PRINT y - x
_DISPLAY
LOOP UNTIL INKEY$ <> ""
StopRecording
SaveRecording ("test.wav")
PlayRecording ("test.wav")
_TITLE "Waveform Display"
SCREEN GetWaveform("test.wav", "640x480")
DECLARE DYNAMIC LIBRARY "WINMM"
FUNCTION mciSendStringA% (lpstrCommand AS STRING, lpstrReturnString AS STRING, BYVAL uReturnLength AS _UNSIGNED LONG, BYVAL hwndCallback AS LONG)
FUNCTION mciGetErrorStringA% (BYVAL dwError AS LONG, lpstrBuffer AS STRING, BYVAL uLength AS _UNSIGNED LONG)
END DECLARE
SUB StartRecording
DIM a AS LONG
a = mciSendStringA("open new type waveaudio alias capture" + CHR$(0), "", 0, 0)
IF a THEN
DIM x AS INTEGER
DIM MCIError AS STRING
MCIError = SPACE$(255)
x = mciGetErrorStringA(a, MCIError, LEN(MCIError))
PRINT MCIError
END
ELSE
a = mciSendStringA("set capture time format ms bitspersample 16 channels 2 samplespersec 48000 bytespersec 192000 alignment 4" + CHR$(0), "", 0, 0)
a = mciSendStringA("record capture" + CHR$(0), "", 0, 0)
END IF
END SUB
SUB StopRecording
DIM a AS LONG
a = mciSendStringA("stop capture" + CHR$(0), "", 0, 0)
END SUB
SUB SaveRecording (file AS STRING)
DIM a AS LONG
a = mciSendStringA("save capture " + CHR$(34) + file + CHR$(34) + CHR$(0), "", 0, 0)
a = mciSendStringA("close capture" + CHR$(0), "", 0, 0)
END SUB
SUB PlayRecording (file AS STRING)
DIM a AS LONG
a = mciSendStringA("play " + CHR$(34) + file + CHR$(34) + CHR$(0), "", 0, 0)
END SUB
FUNCTION GetWaveform& (file AS STRING, size AS STRING)
IF _FILEEXISTS("output.png") THEN
KILL "output.png"
END IF
SHELL _HIDE "ffmpeg -i " + CHR$(34) + file + CHR$(34) + " -filter_complex " + CHR$(34) + "showwavespic=s=" + size + CHR$(34) + " -frames:v 1 output.png"
GetWaveform = _LOADIMAGE("output.png", 32)
END FUNCTION
Tread on those who tread on you
Posts: 2,171
Threads: 222
Joined: Apr 2022
Reputation:
103
Curious. The "Save" in API format. Do you know the folder MS saves your "test.wav" sound file in, to look up the file after it is saved? If so, would there be anyway in this code to have it saved to a different specified folder? If not, knowing where it is saved would just take a simple file move operation with SHELL or in QB64 with NAME AS.
Pete
Posts: 733
Threads: 30
Joined: Apr 2022
Reputation:
43
(10-13-2022, 05:56 PM)Pete Wrote: Curious. The "Save" in API format. Do you know the folder MS saves your "test.wav" sound file in, to look up the file after it is saved? If so, would there be anyway in this code to have it saved to a different specified folder? If not, knowing where it is saved would just take a simple file move operation with SHELL or in QB64 with NAME AS.
Pete @Pete
All you'd need to do would be to specify your path. I left it as just the filename because it defaults to the current working directory as the save directory.
Tread on those who tread on you
Posts: 2,171
Threads: 222
Joined: Apr 2022
Reputation:
103
Nice!
Hey, I see the @ messaging feature failed to register in your post. Mine does that all the friggin'. time. Old browser, I guess. I always have to hit quick edit, do nothing, and then save changes to get it to make a hyperlink.
Pete
Shoot first and shoot people who ask questions, later.
|