开发者

BASIC - activate microphone recording on keypress?

开发者 https://www.devze.com 2022-12-18 04:04 出处:网络
I am charged with an old BASIC progr开发者_如何学Pythonam that needs to be altered to activate microphone recording on a specific keypress. I\'m having trouble finding out how.

I am charged with an old BASIC progr开发者_如何学Pythonam that needs to be altered to activate microphone recording on a specific keypress. I'm having trouble finding out how.

Anyone here able to shed any light?

Thanks for any help.

Edit: I'm pretty sure it was originally written for GW-BASIC.


Since it sounds like you don't have any of the audio code written already, my advice is that you don't try to record from GW-BASIC. There are no built-in functions for accessing the sound card (SOUND and BEEP don't count, as they work with the PC speaker), and sending SoundBlaster control codes is unreliable at best in Windows. Use a secondary, Windows-native program to record.

As for the BASIC code, you're going to have to poll the keyboard. Example:

100 PRINT "Press any key to continue"
110 A$ = INKEY$
120 IF A$ = "" THEN GOTO 110
130 IF A$ = CHR$(1) THEN GOSUB 1000
140 PRINT "Rest of code goes here..."
1000 ' Ctrl+A triggered the microphone
1010 PRINT "Starting microphone recording."
1020 SHELL "otherprg --startrecording"
1030 RETURN

Substitute your preferred key code. If you use INPUT, there's a way--the KEY statement?--to make a function key insert text of your choice. Use KEY to insert, say, CHR$(2)+CHR$(13) (^B plus Enter) when the function key is pressed, then in every INPUT call scan the results for CHR$(2) using INSTR, and branch to the microphone code as desired.

This still won't work if you're using INPUT to read numbers, though. Seriously, unless the microphone recording case is extremely constrained, you're setting yourself up for hideous code that only mostly works.

EDIT: And all this is skating around the biggest problem: GW-BASIC is single-tasking. When you're recording from the mic, you're not able to do real work elsewhere in the program, and vice versa.

0

精彩评论

暂无评论...
验证码 换一张
取 消