簡體   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