主题:  在D8中如何实现录音功能?

李剑

职务:普通成员
等级:1
金币:0.0
发贴:29
#12002/5/14 19:18:34
不知在d8中是否有录制声音的命令?我记得老早以前有人问过。



laosan

职务:普通成员
等级:1
金币:0.0
发贴:78
#22002/5/14 23:01:23
用MCI吧,可以录音,效果不错。
很久以前做的,没有测试。发给你了,希望有用。

不过想要实现声波比对等功能就要用插件了。



我就是我

职务:版主
等级:6
金币:14.0
发贴:5466
#32002/5/15 2:12:31
Audio Xtra 测试报告
Audio Xtra 是一个可以使在Driector中,直接对硬盘进行录音和播放的插件,它支持Macintosh 的*.aif 和windows的*.wav的声音格式,及8bit和16bit的11kHz到44kHz的声音采样频率 。同时,在录音后可以实时的显示声音的声波震动的曲线图。在录音操作中,系统必须生成一个临时的文件。(所有的操作需要有声卡及话筒等录音设备)
基本操作:
1、setSoundType (instance, "file", string filePath, string playOrReco
rd )——指定音文件的路径和具体的操作(录音或播放)。

filePath: 完整的路径文件名
playOrRecord: 选择 "播放" 或 "录音"

Examples:
setSoundType(audioInstance,"file","C:\TEMP\NEWFILE.WAV","record"

setSoundType(audioInstance,"file",the moviePath & "SONG.AIF","play"

2、clearSoundType ( instance)——清除声音,如果你要在director中用“puppetsound”或“playfile”播放声音,先要清除Audio Xtra的声音。
Example:

clearSoundType(audioInstance)

3、play ( instance)——播放声音(必须先设置setSoundType )

Example:

on startTheSound
global audioInstance
set result = play(audioInstance)
if result < 0 then
-- 如果result的值大于0,说明有错误
alert "播放声音有错误"
end if
end

4、record ( instance)——录音(声音文件不能大于2G)

Example:

on startRecording
global audioInstance , isRecording
set err = record(audioInstance)
if err < 0 then
alert "A recording error occurred"
else
set isRecording = TRUE
go "RecordFrame"
end if
end

on exitFrame
-- loop on a frame while recording
global audioInstance, isRecording
if status(audioInstance) = 5 then
-- still recording
go the frame
else
if status(audioInstance) = 8 then
-- a recording error occurred
set err = getError(audioInstance)
put "Error " & err into field "Recording status"
end if
set isRecording = FALSE
go "RecordingOverFrame"
end if
end

5、stop ( instance)——停止播放或录音

Example:

stop(audioInstance)

6、pause ( instance)——暂停播放或录音

Example:

pause(audioInstance)

7、setSampleRate (instance, integer sampleRate )——设置采样频率

注意:你必须把采样频率转化为整数,如 11.025 kHZ = 11025 。如果没有设置,系统将以默 认的方式输出

Example:

-- This handler will set the sampling rate to the highest possible
-- for the current input device

on SetBestSampling
global audioInstance
-- A value of 0 indicates the best sampling rate possible
setSampleRate(audioInstance,0)
end

-- This handler will try to set the sampling rate to 44kHz and if
-- not available will set to 22kHz.

on Set44Sampling
global audioInstance
-- A value of 5 indicates 44kHz sampling
set err = setSampleRate(audioInstance,44100)
-- If 44kHz isn't supported, try to go to 22.050 kHz
if err = -225 then
set err = setSampleRate(audioInstance,22050)
-- If this doesn't work, we will set it to the highest
-- rate possible
if err = -225 then
setSampleRate(audioInstance,0)
end if
end if
end



李剑

职务:普通成员
等级:1
金币:0.0
发贴:29
#42002/5/15 10:13:02
非常感谢,laosan和fei
不知那有Audio Xtra ,是不是共享的。