录音和播放

练习: 声音录制 / 播放, MIDI 播放

编写一个程序能够录制和播放声音,并能被程序菜单控制:

  1. 你需要装入 audio module 来使用:

    audio.Sound.play() 用来播放声音

    audio.Sound.record() 用来录制声音

  2. 你需要打开和关闭所使用的声音文件

    audio.Sound.open(filename)

    audio.Sound.close()

注意:附加的属性请查看 API_Reference_for_Python.pdf(英文) 文档。

  • 示例代码: ex_soundrecorder.py
  • 说明文件: ex_soundrecorder_descr.py

MIDI 播放

要播放MIDI文件也是可行的,这里有一个简单的播放器示例。

示例代码: ex_midiplayer.py

注意: 在你运行上面的示例代码前需要把以下文件放置到你手机的记忆卡中 (location e:\\ )

Midi file 1: sound1.mid

Midi file 1: sound2.mid

Link to MIDI in general

其他支持的音频格式:
AMR, MP3, AAC 和 Real Audio

Share

0 Responses to “录音和播放”


  • No Comments

Leave a Reply