分享

maya 声音系统

 ggandbb 2011-05-06

maya 声音系统(pymedia)

  (2011-04-23 20:45:00)
标签: 

杂谈

  开了声音看才知道效果:

 首先我们需要从网上下载两个模块:pymedia和scipy(或者用numpy也可以)
官方下载地址如下,国内搜索可以有得下载,看清楚你的py版本:
pymedia地址:
http:///projects/pymedia/files/pymedia/

scipy地址:
http:///scipy-superpack/

SciPy是一个开源的Python算法库和数学工具包。
SciPy包含的模块有最优化、线性代数、积分、插值、特殊函数、快速傅里叶变换、信号处理和图像处理、常微分方程求解和其他科学与工程中常用的计算。与其功能相类似的软件还有MATLAB、GNU Octave和Scilab。

重点是pymedia:
Pymedia 是个 C/C++/Python 的多媒体模块,可以对包括 mp3/ogg/avi等多媒体格式文件进行编码解码和播放,基于 ffmpeg 提供了简单的 Python 接口。

PyMedia was built to be really simple and flexible at the same time. See tutorial for example. It allows you to create your own mutimedia applications in a matter of minutes and adjust it to your needs using other components. Python language is choosen because of simple semantics, complete and reach set of features.

pymedia help:

http:///docs/pymedia.audio.sound.html

http:///

在maya里面我利用pymedia播放mp3或者wav的常用音频文件,pymedia调用类来构建一个音频的object,利用里面的构造函数 return frameRate 和 frameNumber 还有voiceWide,输出的声音数据是二进制代码,我利用 scipy或者numpy把它转化人类可读数据格式,其中输出为channels声道,我随便挑选其中一个,然后写出文档,接着用MAYA读取,但是 maya的frameRate和pymedia输出是不一样的,所以我按比例进行了转换,转换成maya可读的帧率。接着就可以在表达式里面进行数据控制了。

PS:由于振幅输出是比较难控制,最好利用maya的linstep()*emitter来控制比较精确,不然声音数据是十分敏感的

maya <wbr>声音系统(pymedia)

maya <wbr>声音系统(pymedia)


Installation:

"Pymedia is a Python library for accessing and manipulating media files. It makes audio and video playback/creation a snap for even a newcomer to programming." There is a deb installer available for pymedia 1.3.5 but not for 1.3.7 So I decided to write this howto.
First install all the dependencies:
sudo apt-get install python-dev libogg-dev libvorbis-dev liblame-dev libfaad2-dev libasound2-dev python-pygame
        (Pygame is not really necessary, but recommended.)
Extract a download of pymedia-*.tgz and open a terminal in the extracted folder, so we can build pymedia:
python setup.py build
      
This should display:
Using UNIX configuration...
      
        OGG : found
        VORBIS : found
        FAAD : found
        MP3LAME : found
        VORBISENC : found
        ALSA : found
        Continue building pymedia ? [Y,n]:
      
If everything is found press Y
Finally install pymedia:
sudo python setup.py install
      
Test if pymedia installed correctly by typing this at the python shell:
import pymedia
      
        ==================
      
        Recently, I needed to use pymedia, for some audio and video encoding. The problem though, is that pymedia was nowhere to be found in the Ubuntu Hardy Heron package repository, and the only .deb installation candidate from the pymedia website was for an older version of pymedia and Python 2.4. Not wanting to run an old version and having Python 2.5 as a requirement, I needed to compile the package myself–no easy task, it turns out.
      
        Step 1. Get pymedia
      
        wget http://internap.dl./sourceforge/pymedia/pymedia-1.3.7.3.tar.gz
        tar xzvf pymedia-1.3.7.3.tar.gz
        cd pymedia-*
        Step 2: Get the pymedia dependencies (as noted here).
      
        sudo apt-get install python-dev libogg-dev libvorbis-dev liblame-dev libfaad-dev libasound2-dev python-pygame
        Step 3. Get GCC 3.4 (pymedia will not compile with GCC 4.0)
      
        sudo apt-get install gcc-3.4 g++-3.4
        export CC=gcc-3.4
        Step 4. Build/compile pymedia
      
        python setup.py build
        Step 5. Be a good Ubuntu user with checkinstall
        Checkinstall is great because it installs the package as a .deb file.
      
        sudo apt-get install checkinstall
        sudo checkinstall python setup.py install
        Note: If you want to be a bad Ubuntu user, you can run “sudo python setup.py install” instead of the checkinstall command.
      
        Step 6. Try it out
      
        python
        >>> import pymedia



    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多