为了好玩,我正在用Python编写一台小型鼓机。我在谷歌上搜索了一些,并在音乐和基本音频上找到了python页面,在生成音频文件上找到了一个StackOverflow问题,但是是一个适合音乐创作的不错的库。这里有人试过做这种事吗?如果是的话,你的解决办法是什么?不管是我找到的,还是我还没找到的东西,都是一个很好的音频操作库吗?
最低限度,我希望能够在python中执行类似于胆量范围的操作,但是如果有人知道一个库可以做得更多.我在认真地听呢。
发布于 2008-09-20 19:51:39
仔细看看cSounds。有Python绑定允许您进行相当灵活的数字合成。也有一些相当完整的包可用。
有关包,请参见http://www.csounds.com/node/188。
有关http://www.csounds.com/journal/issue6/pythonOpcodes.html脚本在cSounds中的信息,请参阅cSounds。
发布于 2008-09-20 18:33:16
我几年前就不得不这么做了。我用了吡喹酮。我不确定它是否还在附近,这是我在玩的时候编写的一些测试代码。不过,它大约有3年历史了。
编辑:示例代码播放MP3文件
import pymedia
import time
demuxer = pymedia.muxer.Demuxer('mp3') #this thing decodes the multipart file i call it a demucker
f = open(r"path to \song.mp3", 'rb')
spot = f.read()
frames = demuxer.parse(spot)
print 'read it has %i frames' % len(frames)
decoder = pymedia.audio.acodec.Decoder(demuxer.streams[0]) #this thing does the actual decoding
frame = decoder.decode(spot)
print dir(frame)
#sys.exit(1)
sound = pymedia.audio.sound
print frame.bitrate, frame.sample_rate
song = sound.Output( frame.sample_rate, frame.channels, 16 ) #this thing handles playing the song
while len(spot) > 0:
try:
if frame: song.play(frame.data)
spot = f.read(512)
frame = decoder.decode(spot)
except:
pass
while song.isPlaying(): time.sleep(.05)
print 'well done'发布于 2008-09-20 18:01:39
有多种Python音乐软件,你可以找到一个目录这里。
如果您向下滚动链接的页面,您会发现一个关于Python中的音乐编程的部分描述了几个音乐创建包,包括MusicKit和PySndObj。
https://stackoverflow.com/questions/108848
复制相似问题