基本 - 按键时激活麦克风录音?
我负责一个旧的 BASIC 程序,需要对其进行更改才能在特定按键上激活麦克风录音。我很难找到方法。
这里有人能提供任何线索吗?
感谢您的任何帮助。
编辑:我很确定它最初是为 GW-BASIC 编写的。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为听起来您还没有编写任何音频代码,所以我的建议是您不要尝试从 GW-BASIC 进行录制。没有用于访问声卡的内置功能(SOUND 和 BEEP 不算在内,因为它们与 PC 扬声器配合使用),并且在 Windows 中发送 SoundBlaster 控制代码充其量也是不可靠的。使用辅助 Windows 本机程序进行录制。
至于 BASIC 代码,您将不得不轮询键盘。示例:
替换您首选的密钥代码。如果您使用 INPUT,有一种方法(KEY 语句?)可以使功能键插入您选择的文本。当按下功能键时,使用 KEY 插入 CHR$(2)+CHR$(13)(^B 加 Enter),然后在每个 INPUT 调用中使用 INSTR 扫描 CHR$(2) 的结果,然后分支根据需要添加到麦克风代码。
不过,如果您使用 INPUT 来读取数字,这仍然不起作用。说真的,除非麦克风录音情况受到极大限制,否则您将自己设置为只能在大多数情况下工作的可怕代码。
编辑: 所有这一切都围绕着最大的问题: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:
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.