English 中文(简体)
BASIC - activate microphone recording on keypress?
原标题:

I am charged with an old BASIC program 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.

问题回答

暂无回答




相关问题
Why running a service as Local System is bad on windows?

I am trying to find out the difference between difference service account types. I tumbled upon this question. The answer was because it has powerful access to local resources, and Network Service ...

Programmatically detect Windows cluster configuration?

Does anyone know how to programatically detect that a Windows server is part of a cluster? Further, is it possible to detect that the server is the active or passive node? [Edit] And detect it from ...

get file icon for Outlook appointment (.msg)

I ve read Get File Icon used by Shell and the other similar posts - and already use SHFileInfo to get the associated icon for any given extension, and that works great. However, Outlook uses ".msg" ...

Identifying idle state on a windows machine

I know about the GetLastInputInfo method but that would only give me the duration since last user input - keyboard or mouse. If a user input was last received 10 minutes ago, that wouldn t mean the ...

Terminating a thread gracefully not using TerminateThread()

My application creates a thread and that runs in the background all the time. I can only terminate the thread manually, not from within the thread callback function. At the moment I am using ...

热门标签