Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Composing music with Abjad on CoCalc

Views: 202
Kernel: Python 3 (Ubuntu Linux)

Using Abjad and Lilypond in CoCalc

In a CoCalc terminal, run

pip3 install Abjad pip3 install abjad-ext-ipython

Then, as this worksheet shows, displaying music works!

What does not work so far is playing music. This is because abjad.play relies on timidity. Feature request for abjad.play: allow to specify a player, such as a javascript player.

For example, by allowing abjad.play(staff, player='midijs') or similar.

import abjad
%load_ext abjadext.ipython
note = abjad.Note()
note
Note("c'4")
abjad.show(note)
Image in a Jupyter notebook
from random import randint pitch_numbers = [randint(-7,24) for x in range(100)] pitch_numbers[:10]
[8, 10, 11, 22, 3, 19, 22, -4, 20, -7]
notes = [abjad.Note(x,(1,32)) for x in pitch_numbers]
staff = abjad.Staff(notes)
abjad.show(staff)
Image in a Jupyter notebook
abjad.play(staff)
--------------------------------------------------------------------------- CalledProcessError Traceback (most recent call last) <ipython-input-14-86a9b915fe20> in <module>() ----> 1 abjad.play(staff) ~/.local/lib/python3.6/site-packages/abjadext/ipython/Play.py in __call__(self, argument) 24 if not hasattr(argument, '__illustrate__'): 25 raise TypeError('Cannot play {!r}'.format(type(argument))) ---> 26 has_vorbis = self._check_for_vorbis() 27 with tempfile.TemporaryDirectory() as temporary_directory: 28 temporary_directory = pathlib.Path(temporary_directory) ~/.local/lib/python3.6/site-packages/abjadext/ipython/Play.py in _check_for_vorbis(self) 48 def _check_for_vorbis(self): 49 has_vorbis = False ---> 50 output = subprocess.check_output('timidity --help', shell=True) 51 output = output.decode('utf-8') 52 for line in output.splitlines(): /usr/lib/python3.6/subprocess.py in check_output(timeout, *popenargs, **kwargs) 334 335 return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, --> 336 **kwargs).stdout 337 338 /usr/lib/python3.6/subprocess.py in run(input, timeout, check, *popenargs, **kwargs) 416 if check and retcode: 417 raise CalledProcessError(retcode, process.args, --> 418 output=stdout, stderr=stderr) 419 return CompletedProcess(process.args, retcode, stdout, stderr) 420 CalledProcessError: Command 'timidity --help' returned non-zero exit status 127.