Python音乐库?

akd*_*dom 38 python audio

我正在寻找用Python编写一个小鼓机来获得乐趣.我搜索了一些,发现了关于音乐基本音频的python页面以及关于生成音频文件的StackOverflow问题,但我正在寻找的是一个体面的音乐创建库.有没有人在这里尝试做过这样的事情?如果是这样,你的解决方案是什么?什么,无论是我发现的,还是我没有找到的东西,都会成为一个体面的音频处理库?

最低限度,我希望能够在Python中做类似于Audacity的范围,但是如果有人知道可以做更多的库...我都是耳朵.

S.L*_*ott 14

仔细看看cSounds.Python绑定允许您进行非常灵活的数字合成.还有一些非常完整的包.

有关包,请访问http://www.csounds.com/node/188.

有关cSounds中Python脚本的信息,请访问http://www.csounds.com/journal/issue6/pythonOpcodes.html.


tim*_*adh 7

几年前我不得不做这件事.我用过pymedia.我不确定它是否仍然存在,这是我在玩它时写的一些测试代码.虽然它大约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'
Run Code Online (Sandbox Code Playgroud)


Joe*_*ora 4

Python 音乐软件有很多种,你可以在这里找到目录。

如果向下滚动链接页面,您会发现有关Python 音乐编程的部分,描述了多个音乐创作包,包括MusicKitPySndObj