简体   繁体   English

Python音频库可同时创建和播放音频

[英]Python audio library for simultaneous audio creation and playback

I'm working on an audio creation framework. 我正在开发音频创建框架。 It'll be generating large audio files, say 3 minute long audio files that take about 1 minute to generate. 它将生成大型音频文件,例如3分钟长的音频文件,大约需要1分钟的时间来生成。 So what I want is a system much like streaming audio from the internet, where I play the sound as I generate it. 因此,我想要的是一个类似于从互联网流式传输音频的系统,当我生成声音时就在其中播放声音。
Pygame's mixer allows me to edit the sound as it's playing. Pygame的混音器允许我在播放声音时对其进行编辑。 But I cannot figure out how to change the sample rate, sample size, or number of channels. 但是我不知道如何更改采样率,采样大小或通道数。
Snack allows me to edit sounds, as well as their sample rate, sample size, length, and number of channels. 小吃允许我编辑声音以及它们的采样率,样本大小,长度和通道数。 But I cannot figure out how to edit sounds as they are playing. 但是我无法弄清楚如何在播放声音时对其进行编辑。

Could anybody point me to a library that allows me to edit a sound as it is playing, as well as configure the number of channels, sample rate, and length (all known ahead of time)? 有人可以将我指向一个允许我在播放声音时对其进行编辑,以及配置声道数量,采样率和长度(所有这些都是预先知道的)的库吗? If not, perhaps somebody knows of a tutorial to do this in C++? 如果不是,也许有人知道使用C ++进行此操作的教程吗?

[ EDIT ] Pymedia.audio would work fine for me. [ 编辑 ] Pymedia.audio对我来说可以正常工作。 However, I can't get it to work under Python 2.6. 但是,我无法使其在Python 2.6下工作。 Any ideas? 有任何想法吗?

pymedia.audio does work with Python 2.6. pymedia.audio 确实适用于Python 2.6。 Take a look at this SO post: Pymedia installation on Windows with Python 2.6 看看这个SO帖子: 在Windows上使用Python 2.6进行Pymedia安装

You can append audio to Output objects, as they are playing. 您可以在正在播放的输出对象上附加音频。 So as each sample is generated, it can also be appended to the stream. 因此,在生成每个样本时,也可以将其附加到流中。 The example in their documentation shows just how to do this: http://pymedia.org/docs/pymedia.audio.sound.html 他们文档中的示例显示了如何执行此操作: http : //pymedia.org/docs/pymedia.audio.sound.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM