shorepine / amy

AMY - A high-performance fixed-point Music synthesizer librarY for microcontrollers
https://shorepine.github.io/amy/
MIT License
224 stars 14 forks source link

can't import Amy #181

Closed steeley closed 3 months ago

steeley commented 3 months ago

I have installed the library as per the readme instructions, and I can use make ./amy-example to compile and hear sound.

I can't run Amy in python- import Amy just says no module found. I'm on Intel MacBook osx Ventura 13.6.9, python 3.12

output from pip install: pip install . . DEPRECATION: Loading egg at /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/qt_material-2.14-py3.12.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation. Discussion can be found at https://github.com/pypa/pip/issues/12330 Processing /Users/ian/amyDSP/src Preparing metadata (setup.py) ... done Building wheels for collected packages: libamy Building wheel for libamy (setup.py) ... done Created wheel for libamy: filename=libamy-0.0.0-cp312-cp312-macosx_10_9_universal2.whl size=1901127 sha256=94dd752bdbb88a88cb047a65b1464f3e76232cb2afdb8e9c253f6d7a6860eae2 Stored in directory: /private/var/folders/w3/rzctjzp952nb7qxljdy7rw600000gn/T/pip-ephem-wheel-cache-088_l58h/wheels/4b/5a/24/1833746e535b7db6337de9b5c3bbbf96c80a511c86cf1ea634 Successfully built libamy Installing collected packages: libamy Successfully installed libamy-0.0.0

bwhitman commented 3 months ago

Try make test

If that works (you see test results) try running python3 and then importing libamy

steeley commented 3 months ago

thanks for the suggestion, but still no go. the test compile runs and produces the result below when run from the terminal.

In the terminal: python3 import amay Amy.drums()

this runs without error but produces no sound.

Also I cannot use the same python3 from within the Thonny editor to import amy. it just says 'module not found'

output from test: python3 test.py TestSineOsc : signal=-29.7 dB err=-100.0 dB TestPulseOsc : signal=-27.8 dB err=-100.0 dB TestSawDownOsc : signal=-29.9 dB err=-100.0 dB TestSawUpOsc : signal=-32.9 dB err=-100.0 dB TestTriangleOsc : signal=-31.2 dB err=-100.0 dB TestNoiseOsc : signal=-29.7 dB err=-30.5 dB TestPcm : signal=-40.8 dB err=-100.0 dB TestPcmShift : signal=-43.6 dB err=-100.0 dB TestPcmLoop : signal=-39.6 dB err=-100.0 dB TestPartial : signal=-43.5 dB err=-41.4 dB TestSineEnv : signal=-38.9 dB err=-100.0 dB TestAlgo : signal=-35.8 dB err=-100.0 dB TestAlgo2 : signal=-33.7 dB err=-100.0 dB TestFilter : signal=-25.1 dB err=-100.0 dB TestFilter24 : signal=-10.8 dB err=-100.0 dB TestFilterLFO : signal=-29.0 dB err=-100.0 dB TestLFO : signal=-29.7 dB err=-99.1 dB TestDuty : signal=-35.2 dB err=-100.0 dB TestPWM : signal=-28.5 dB err=-100.0 dB TestGlobalEQ : signal=-35.9 dB err=-100.0 dB TestChorus : signal=-22.1 dB err=-100.0 dB TestBrass : signal=-36.1 dB err=-100.0 dB TestBrass2 : signal=-37.2 dB err=-97.4 dB TestGuitar : signal=-33.0 dB err=-100.0 dB TestBleep : signal=-31.4 dB err=-100.0 dB TestOverload : signal=-1.9 dB err=-100.0 dB TestJunoPatch : signal=-20.5 dB err=-89.4 dB TestJunoClip : signal=-7.0 dB err=-66.9 dB TestLowVcf : signal=-22.0 dB err=-100.0 dB TestLowerVcf : signal=-14.0 dB err=-100.0 dB TestFlutesEq : signal=-39.1 dB err=-100.0 dB TestOscBD : signal=-32.2 dB err=-100.0 dB TestChainedOsc : signal=-24.9 dB err=-100.0 dB TestJunoTrumpetPatch: signal=-40.8 dB err=-100.0 dB TestJunoCheapTrumpetPatch: signal=-42.1 dB err=-100.0 dB TestFilterReleaseGlitch: signal=-32.9 dB err=-100.0 dB RENDER_OSC_WAVE: 81 calls 136us total [ 1.60% wall 29.76% render] 1us per call COMPUTE_BREAKPOINT_SCALE: 1012 calls 18us total [ 0.21% wall 3.94% render] 0us per call HOLD_AND_MODIFY: 253 calls 55us total [ 0.65% wall 12.04% render] 0us per call FILTER_PROCESS: 81 calls 251us total [ 2.95% wall 54.92% render] 3us per call FILTER_PROCESS_STAGE0: 81 calls 12us total [ 0.14% wall 2.63% render] 0us per call FILTER_PROCESS_STAGE1: 81 calls 229us total [ 2.69% wall 50.11% render] 2us per call ADD_DELTA_TO_QUEUE: 9 calls 2us total [ 0.02% wall 0.44% render] 0us per call AMY_ADD_EVENT: 4 calls 2us total [ 0.02% wall 0.44% render] 0us per call PLAY_EVENT: 9 calls 2us total [ 0.02% wall 0.44% render] 0us per call MIX_WITH_PAN: 81 calls 17us total [ 0.20% wall 3.72% render] 0us per call AMY_RENDER: 172 calls 457us total [ 5.35% wall 100.00% render] 2us per call AMY_PREPARE_BUFFER: 172 calls 47us total [ 0.55% wall 10.28% render] 0us per call AMY_FILL_BUFFER: 172 calls 109us total [ 1.28% wall 23.85% render] 0us per call AMY_PARSE_MESSAGE: 4 calls 2us total [ 0.02% wall 0.44% render] 0us per call RENDER_LUT_CUB: 70 calls 102us total [ 1.19% wall 22.32% render] 1us per call RENDER_LPF_LUT: 70 calls 108us total [ 1.26% wall 23.63% render] 1us per call DSPS_BIQUAD_F32_ANSI_SPLIT_FB_TWICE: 81 calls 223us total [ 2.61% wall 48.80% render] 2us per call SCAN_MAX: 162 calls 6us total [ 0.07% wall 1.31% render] 0us per call tests done.

dpwe commented 3 months ago

You need to start the audio:

$ python3 Python 3.12.4 (main, Jun 6 2024, 18:26:44) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin Type "help", "copyright", "credits" or "license" for more information.

import amy amy.live() amy.drums()

If you have anything more than the default speakers attached, you might need:

amy.live(audio_device=1) or some other number.

Thonny IIUC is a front-end for micropython running on device, so its available libraries are unrelated to whatever you can get with python running on your host. It should be possible to get an amy library available on your target micropython device, but we haven't tried that. Instead, Tulip builds as a complete Micropython environment including Amy baked-in.

DAn.

On Thu, Aug 22, 2024 at 10:09 AM steeley @.***> wrote:

thanks for the suggestion, but still no go. the test compile runs and produces the result below when run from the terminal.

In the terminal: python3 import amay Amy.drums()

this runs without error but produces no sound.

Also I cannot use the same python3 from within the Thonny editor to import amy. it just says 'module not found'

output from test: python3 test.py TestSineOsc : signal=-29.7 dB err=-100.0 dB TestPulseOsc : signal=-27.8 dB err=-100.0 dB TestSawDownOsc : signal=-29.9 dB err=-100.0 dB TestSawUpOsc : signal=-32.9 dB err=-100.0 dB TestTriangleOsc : signal=-31.2 dB err=-100.0 dB TestNoiseOsc : signal=-29.7 dB err=-30.5 dB TestPcm : signal=-40.8 dB err=-100.0 dB TestPcmShift : signal=-43.6 dB err=-100.0 dB TestPcmLoop : signal=-39.6 dB err=-100.0 dB TestPartial : signal=-43.5 dB err=-41.4 dB TestSineEnv : signal=-38.9 dB err=-100.0 dB TestAlgo : signal=-35.8 dB err=-100.0 dB TestAlgo2 : signal=-33.7 dB err=-100.0 dB TestFilter : signal=-25.1 dB err=-100.0 dB TestFilter24 : signal=-10.8 dB err=-100.0 dB TestFilterLFO : signal=-29.0 dB err=-100.0 dB TestLFO : signal=-29.7 dB err=-99.1 dB TestDuty : signal=-35.2 dB err=-100.0 dB TestPWM : signal=-28.5 dB err=-100.0 dB TestGlobalEQ : signal=-35.9 dB err=-100.0 dB TestChorus : signal=-22.1 dB err=-100.0 dB TestBrass : signal=-36.1 dB err=-100.0 dB TestBrass2 : signal=-37.2 dB err=-97.4 dB TestGuitar : signal=-33.0 dB err=-100.0 dB TestBleep : signal=-31.4 dB err=-100.0 dB TestOverload : signal=-1.9 dB err=-100.0 dB TestJunoPatch : signal=-20.5 dB err=-89.4 dB TestJunoClip : signal=-7.0 dB err=-66.9 dB TestLowVcf : signal=-22.0 dB err=-100.0 dB TestLowerVcf : signal=-14.0 dB err=-100.0 dB TestFlutesEq : signal=-39.1 dB err=-100.0 dB TestOscBD : signal=-32.2 dB err=-100.0 dB TestChainedOsc : signal=-24.9 dB err=-100.0 dB TestJunoTrumpetPatch: signal=-40.8 dB err=-100.0 dB TestJunoCheapTrumpetPatch: signal=-42.1 dB err=-100.0 dB TestFilterReleaseGlitch: signal=-32.9 dB err=-100.0 dB RENDER_OSC_WAVE: 81 calls 136us total [ 1.60% wall 29.76% render] 1us per call COMPUTE_BREAKPOINT_SCALE: 1012 calls 18us total [ 0.21% wall 3.94% render] 0us per call HOLD_AND_MODIFY: 253 calls 55us total [ 0.65% wall 12.04% render] 0us per call FILTER_PROCESS: 81 calls 251us total [ 2.95% wall 54.92% render] 3us per call FILTER_PROCESS_STAGE0: 81 calls 12us total [ 0.14% wall 2.63% render] 0us per call FILTER_PROCESS_STAGE1: 81 calls 229us total [ 2.69% wall 50.11% render] 2us per call ADD_DELTA_TO_QUEUE: 9 calls 2us total [ 0.02% wall 0.44% render] 0us per call AMY_ADD_EVENT: 4 calls 2us total [ 0.02% wall 0.44% render] 0us per call PLAY_EVENT: 9 calls 2us total [ 0.02% wall 0.44% render] 0us per call MIX_WITH_PAN: 81 calls 17us total [ 0.20% wall 3.72% render] 0us per call AMY_RENDER: 172 calls 457us total [ 5.35% wall 100.00% render] 2us per call AMY_PREPARE_BUFFER: 172 calls 47us total [ 0.55% wall 10.28% render] 0us per call AMY_FILL_BUFFER: 172 calls 109us total [ 1.28% wall 23.85% render] 0us per call AMY_PARSE_MESSAGE: 4 calls 2us total [ 0.02% wall 0.44% render] 0us per call RENDER_LUT_CUB: 70 calls 102us total [ 1.19% wall 22.32% render] 1us per call RENDER_LPF_LUT: 70 calls 108us total [ 1.26% wall 23.63% render] 1us per call DSPS_BIQUAD_F32_ANSI_SPLIT_FB_TWICE: 81 calls 223us total [ 2.61% wall 48.80% render] 2us per call SCAN_MAX: 162 calls 6us total [ 0.07% wall 1.31% render] 0us per call tests done.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

steeley commented 3 months ago

ok sort off got it working from terminal. I use Thonny with ESP etc and desktop Python stuff and it works well. Shame I can't get it to work with Amy. yes, aware of Tulip.

my goal is to get a DSP/sound/synth DSP lib that works easily on both desktop and embedded stuff.

thanks

bwhitman commented 3 months ago

We have plans to port AMY and the parts of tulip that interact with AMY to pure micropython for things like thonny. But for now you'll have to DIY or use tulip itself. https://github.com/shorepine/tulipcc/issues/309

Glad you got python AMY going on desktop!

dpwe commented 3 months ago

In my experience with Thonny running on an RP2040, installing a library involved dragging an mpy file onto the device when mounted as a mass storage device, then rebooting, and somehow the micropython on the target device was then able to find it (IIRC).

Figuring out how to compile Amy into such an mpy object file should be pretty easy. But to make it run on some arbitrary target device is more than just linking python functions: To run Amy, there needs to be an audio kernel running all the time as a separate thread, and that kernel needs to know where the audio interface is and how to send samples to it. That sounds like a lot more work, I'm not sure how you'd even get a separate thread running under Thonny/stock MicroPython.

steeley commented 3 months ago

got Thonny running with Amy and desktop Python3 - had to reset some paths. I'm just using the desktop python with amy to generate some automated tones and signals to auto test some audio hardware.

thanks again to all for the suggestions