基本 - 按键时激活麦克风录音?

发布于 2024-08-19 15:01:23 字数 149 浏览 5 评论 0原文

我负责一个旧的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

东风软 2024-08-26 15:01:23

因为听起来您还没有编写任何音频代码,所以我的建议是您不要尝试从 GW-BASIC 进行录制。没有用于访问声卡的内置功能(SOUND 和 BEEP 不算在内,因为它们与 PC 扬声器配合使用),并且在 Windows 中发送 SoundBlaster 控制代码充其量也是不可靠的。使用辅助 Windows 本机程序进行录制。

至于 BASIC 代码,您将不得不轮询键盘。示例:

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

替换您首选的密钥代码。如果您使用 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:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文