繁体   English   中英

如何在python 3上生成正弦波音调

[英]How to generate a Sine wave tone on python 3

我想使用1kHz频率的python 3生成正弦音调。 我在stackoverflow上发现了一个老问题(旧问题) ,但这是在使用python 2的pyaudio

我还有其他方法可以使用python 3吗?


尝试安装音阶时出错

Successfully built tonescale propyte shijian sklearn docopt pyprel pytg technico
lor DictObject backcall pyrsistent prometheus-client pandocfilters
Failed to build pyaudio
Installing collected packages: docopt, python-magic, websocket-client, pushbulle
t.py, pickleshare, backcall, ipython-genutils, decorator, traitlets, pygments, p
rompt-toolkit, parso, jedi, colorama, ipython, tornado, pyzmq, jupyter-core, jup
yter-client, ipykernel, pyrsistent, jsonschema, nbformat, entrypoints, pandocfil
ters, webencodings, bleach, mistune, testpath, MarkupSafe, jinja2, defusedxml, n
bconvert, prometheus-client, pywinpty, terminado, Send2Trash, notebook, widgetsn
bextension, ipywidgets, kiwisolver, cycler, pyparsing, matplotlib, scipy, seabor
n, joblib, scikit-learn, sklearn, technicolor, shijian, pyprel, luckydonald-util
s, DictObject, pytg, psutil, propyte, pyaudio, tonescale
  Running setup.py install for pyaudio ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\myUser\appdata\local\programs\python\python37-32\python.exe
' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\myUser\\Ap
pData\\Local\\Temp\\pip-install-zn_0i9s8\\pyaudio\\setup.py'"'"'; __file__='"'"'
C:\\Users\\myUser\\AppData\\Local\\Temp\\pip-install-zn_0i9s8\\pyaudio\\setup.py'"'
"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'
"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'
))' install --record 'C:\Users\myUser\AppData\Local\Temp\pip-record-5j63osr6\instal
l-record.txt' --single-version-externally-managed --compile
         cwd: C:\Users\myUser\AppData\Local\Temp\pip-install-zn_0i9s8\pyaudio\
    Complete output (9 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.7
    copying src\pyaudio.py -> build\lib.win32-3.7
    running build_ext
    building '_portaudio' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual
C++ Build Tools": https://visualstudio.microsoft.com/downloads/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\myUser\appdata\local\progr
ams\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.
argv[0] = '"'"'C:\\Users\\myUser\\AppData\\Local\\Temp\\pip-install-zn_0i9s8\\pyaud
io\\setup.py'"'"'; __file__='"'"'C:\\Users\\myUser\\AppData\\Local\\Temp\\pip-insta
ll-zn_0i9s8\\pyaudio\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__
file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compi
le(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\myUser\AppData\Loca
l\Temp\pip-record-5j63osr6\install-record.txt' --single-version-externally-manag
ed --compile Check the logs for full command output.

音阶安装说明建议使用pyaudio的python3版本:python3-pyaudio。

也有pygame

Windows的pyaudio安装说明建议它应该平稳运行,因为提供了二进制滚轮。 但是他们确实提到,在特殊情况下,可能需要编译PortAudio。

您可能要尝试使用存档中的downrev转盘。

暂无
暂无

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

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