MarcTheSpark / scamp

a Suite in Python for Computer-Assisted Music [MIRROR of https://git.sr.ht/~marcevanstein/scamp]
http://scamp.marcevanstein.com
GNU General Public License v3.0
122 stars 11 forks source link

live play music with scamp? #1

Closed vshesh closed 4 years ago

vshesh commented 5 years ago

hi,

this looks like a cool project! I was a little confused when I opened a terminal and saw that playing notes got me this error regularly:

>>> from scamp import *
WARNING:root:abjad was not found; lilypond output will not be available.
>>> s = Session()
>>> piano 
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    piano
NameError: name 'piano' is not defined
>>> piano = s.new_part('piano')
Using preset Piano Merlin for piano
>>> s.start_recording()
Performance([
   PerformancePart(name='piano', instrument_id=('piano', 0), voices={
      '_unspecified_': [

      ]
   })
])
>>> piano.play_chord([65, 77, 78])
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    piano.play_chord([65, 77, 78])
TypeError: play_chord() missing 2 required positional arguments: 'volume' and 'length'
>>> piano.play_chord([65, 77, 78], 0.5, 1)
>>> piano.play_chord([65, 62, 78], 0.5, 1)
WARNING:root:Clock is running noticeably behind real time (12.88869 s) on a wait call of 1.0 s; probably processing is too heavy.
>>> piano.play_chord([65, 72, 78], 0.5, 1)
WARNING:root:Clock is running noticeably behind real time (3.29461 s) on a wait call of 1.0 s; probably processing is too heavy.
>>> piano.play_chord([65, 72, 78], 0.5, 1)
>>> piano.play_chord([65, 72, 78], 0.5, 1)
>>> piano.play_chord([65, 72, 78], 0.5, 1)
>>> piano.play_chord([65, 72, 78], 0.5, 1)
WARNING:root:Clock is running noticeably behind real time (7.83958 s) on a wait call of 1.0 s; probably processing is too heavy.
>>> piano.play_chord([65, 72, 78], 0.5, 1)
>>> piano.play_chord([65, 72, 78], 0.5, 1)
>>> piano.play_chord([65, 72, 78], 0.5, 1)
>>> piano.play_chord([65, 72, 78], 0.5, 1)
WARNING:root:Clock is running noticeably behind real time (0.68803 s) on a wait call of 1.0 s; probably processing is too heavy.
>>> 

It looks like the "session" concept is designed for immediate playthrough of a score. Is there a way to use this as a "server" of sorts? I want to be able to leave something running and then send notes to it based on changes in another environment (software, tangible interface, etc) and have it play those... or alternatively code up a state machine in python using scamp that responds to some kind of input (OSC messages from a TUIO command, for example)

Thanks!

MarcTheSpark commented 4 years ago

Hi vshesh,

I think we actually corresponded by e-mail about this, but after seeing your question I actually added the ability to call run_as_server on the Session to have it behave as you have described. Simply replace s = Session() with s = Session().run_as_server().

Hopefully that solves the issue!

Marc