ambv / aiotone Goto Github PK
View Code? Open in Web Editor NEWA demo of using AsyncIO for music sequencing
License: MIT License
A demo of using AsyncIO for music sequencing
License: MIT License
Hi Łukasz
I followed your awesome PyCon talk. I did a few similar experiments and I just started to write some music with aiotone.
I have a question about this:
Lines 32 to 33 in e4e999f
I have used async back in the tornado days and didn't do much recently. I would only lock if the code was:
async with self.lock:
await ...
.....
await ...
(Of course we had only yield)
Otherwise there is nothing that can run in between, right? I guess you write it like that in case you change the code to something more complex.
First of all, thank you Łukasz, for the wonderful pycon presentation, and this really inspiring library!
I've tried to get things working on Linux (a somewhat older Ubuntu), and mostly things just work, so that may be a thing that could be noted in the documentation (though I totally understand if you didn't want to add that so as not to have to support it, but perhaps this issue will be helpful to others looking to do similar things in the future.)
For RTMidi to work I had to install the following header packages:
I also worked around a fairly different hardware setup:
I don't have any hardware that can function as a MIDI sequencer so I installed seq24 and had it send MIDI clock events to a MIDI through port.
I have two volca's (beats and nubass) that I'm driving, but they don't have USB, so I got some cheap USB to 5 pin MIDI cables, which works right away. I'm not sure if it's the cables or that my elderly laptop is not processing the queue fast enough, but I ran into a lot of missing notes, and pretty widely varying pulse delta's. The way I solved this was to not send the clock events through to the synths, since they don't really need the clock, when they get the notes sent to them. (It does lose the nice synced step lights, though.)
Hope this helps someone in the future, if there is a better place to put this please let me know, and thanks again, driving hardware synths from Python is turning out to be so much fun!
For anyone who is interested. I built sequencer based on aiotone that is sync-master and drives my DAW. I had quite some jitter compared to other midi-sequencers. Using spin_sleep()
in the main loop, there is much less jitter. Of course there is a tradeoff: higher CPU load.
sleep_resolution
is platform dependent. On linux 0.001s should be a good value. I am not aware of a good way to detect sleep_resolution
.
import asyncio
from time import time
sleep_resolution = 0.001
async def spin_sleep(sleep_time):
deadline = sleep_time + time()
await asyncio.sleep(sleep_time - sleep_resolution)
while deadline > time():
await asyncio.sleep(0)
Currently my code isn't in a state for sharing, but I will put it on github soonish.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.