Jump to content
Sign in to follow this  
Frederic

Triggering event - anonymous functions (like in Javascript)

Recommended Posts

Hello all, 

 

I'm coming from the javascript development world. Here are few musical ideas. Is there a way to implement them thanks to Opusmodus ? 

 

- play a sequence of notes in 30 seconds:

in javascript, it could be pseudo-coded like this: 
 

 setTimeout(function(){ play('c4 d4 e4 f4 g4'); }, 3000); 

 

- play a sequence of notes at a specific event.

in Javascript/jQuery, it is very easy to code anonymous functions that would wait for a specific event to be triggered. Some examples I have in mind:

 

play 'do ré mi' at bar 4

$('4th bar').on(function() { play('c5 d5 e6');});

 

play 'do ré mi' each time note f5 is played

$('f5').on(function() { play('c5 d5 e6');});

repeat the note + octave when f5 is played

$('f5').on(function(this) { play(this + this.octave(1));});

 

In other words: is it possible to trigger an anonymous function with opusmodus, so that a musical phrase will be played at specific event ? 

 

 

Thanks for clarification, best !

Share this post


Link to post
Share on other sites

SLEEP is the function you are looking for.

(sleep time) ; in seconds 

 

The 1st expression will play for 10 second. The 2nd for 4 seconds.

(progn
  (ps 'gm :cl (list (gen-repeat 100 '((s c4 d4 e4 f4 g4)))))
  (sleep 10)
  (ps 'gm :fl (list '(q c5 d5 e5 f5 g5 a5 b5)))
  (sleep 4)
  (ps 'gm :fl (list '(w cs6)))
  )

 

Share this post


Link to post
Share on other sites

but SLEEP is not very precise - would be nic to have in OPMO a real precise trigger, like with OSC (for external players...) 🙂

 

 

 

 

Share this post


Link to post
Share on other sites

the NUMBER is precise, but ... 😉 

 

...but the great thing is, you are very flexible (and open) in OPMO/lisp... and you can trigger also other software/externals from OPMO/lisp  via OSC, i LOVE IT 🙂

 

 

Share this post


Link to post
Share on other sites

Every function which use a time wait (Threads, OSC and other libraries) using SLEEP - very precise indeed. 🙂

Share this post


Link to post
Share on other sites

my colleagues from the computermusic laboratory advised me not to steer external things via internal SLEEP, but also to control the TIME / delay via OSC. perhaps also has to do with the fact that for me different things must be controlled in parallel and synchronized. i don't know...

Share this post


Link to post
Share on other sites

Hello,

 

Ok thanks ! I understand how to mitigate my first use case with SLEEP.

 

But what the second one ? how to play a musical phrase at specific event, like for example when "f5" is played 

 

Thanks again ! 

Share this post


Link to post
Share on other sites

but SLEEP is not very precise

 

The Common Lisp standard actually says that the number of seconds specified as arguments for sleep is approximate:

 

> Causes execution to cease and become dormant for approximately the seconds of real time indicated by seconds, whereupon execution is resumed. 

 

WWW.LISPWORKS.COM

 

Anyway, it seems that at least on a Mac the imprecision is rather regular, see the following discussion with empirical tests.

LISP-HUG.LISPWORKS.NARKIVE.COM

 

Anyway, for realtime scheduling in a musical context one needs likely a proper scheduler for that. 

 

Best,

Torsten

Share this post


Link to post
Share on other sites

thanks!

a.

p.s. 

Quote

Anyway, for realtime scheduling in a musical context one needs likely a proper scheduler for that. 

... that's why i have some other solutions for my needs...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Similar Topics

    • By torstenanders
      The function LENGTH-DIVIDE and friends are a useful device for introducing some rhythmic variation to some material. However, when the processed sequence is a full OMN expression (see example below), then the added notes cause all other parameters to shift forward (additional parameters are added at the end by looping). For introducing only a slight variation to some existing material (e.g., motif) these functions are therefore not so useful, because this shift of all parameters to basically "fill" the new added notes with pitches etc. greatly change the varied material for a listener.
      (length-divide 1 2 '(q f3 leg+m1 q ab3 leg e c4 leg bb3 leg ab3 leg g3))  
      Basically, this is the opposite situation of the situation addressed by swallowing. Swallowing (e.g., with GEN-SWALLOW and the swallow argument of many other functions) avoids the shift of parameters like pitch etc. that would result from removing notes and turning them into rests. For addressing the situation above properly we would need something like the opposite of swallowing, some way to fill in parameters like pitch etc. for new notes to avoid shifting existing notes. I hope my explanation makes sense and you can see why something like the opposite of swallowing would be useful for functions that add notes to some input material.
       
      Now, the tricky question is of course, what parameters (pitch etc.) should be added in such cases. Musically useful and common in the classical literature would be, e.g., repeating the parameters (pitch etc.) of the predecessor note (though that might be a bit too simplistic and annoying at times) or somehow interpolating some pitch gap between the previous and next note with a little scale or arpeggio and only repeating the other parameters like articulations (resulting in some variation that is likely most similar to the input material, so it would be good to have that as an option).  If the pitch interval between the two original notes is too small to add some pitch in between for the new now (or as an option in general for variety), it would also be good  to add some ornamentation (e.g., using PITCH-ORNAMENT), but for a close similarity between the original material and the variation it would be best as an option to apply such ornamentation only to the newly added notes, not all notes. Of course, other options could also be useful for variations that vary the input material a bit more strongly, e.g., some random pitch for the new notes within certain interval bounds.
       
      Does some function that kind of is the opposite of GEN-SWALLOW in that it adds parameters like pitches for subdivided rhythmic values (to avoid the shifting) sound like a good idea?
       
      The idea with the interpolation of gaps could be implemented by turning the original duration values and pitches into some envelope and then reading that envelope with the new rhythmic values. So, that is rather strait forward. However, that would not allow for some ornamentation, because such algorithm would not recognise which notes are new that should be ornamented.
       
      Any other idea perhaps? Thanks! 
    • By AM
      dear all
       
      is there a possibility to change the PAN in every EVENT?
      1)
      like '((q c4 mp pan-30) (e c3 pp pan100))  
      would be interesting for LIVE-CODING
      is there something predifined? like it will come up with microtonality/tuning
       
      2)
      and why does it work with simple-midi-sound (a list in :pan) and not with a player like conTimbre (there is something i don't understand with midi/players/etc)?
       
      thanx for a  hint
      andré
       
      an example: (setf omn '((5q c4 5q 5q 5q 5q 5q 5q 5q) (-q) (e e e e e) (-q) (7q 7q) (3q 3q) (-q) (5q 5q 5q) (7q 7q) (3q 3q 3q 3q) (e e) (-q) (3q 3q 3q 3q 3q) (e e e e e))) ;;; (def-score signature (:title "signature" :key-signature 'atonal :time-signature '(4 4) :tempo 60) (instr ;:port 0 :omn (omn-replace :velocity (pick-norepeat 100 '(pppp ppppp ppp ppp pp p)) (length-diminution 4 (gen-repeat 10 omn))) :tuning (gen-white-noise 100 :scale 0.1) :pan '(1 1 1 1 1 1 1 1 10 30 1 1 1 100 100 80 77 15 100 100 100) :channel 1 :sound 'gm-trumpet))  
    • By Andy
      An unusual request:
      I am using Opusmodus for my next project 'The Last', a dance piece, the subject of which is... death.
      Can anyone point me to some functions that might, with a little creative license, play with the idea of death in terms of, for example, entropy or decay? Or truncation. 
      I'm throwing the ball in the air here so all ideas are welcome!
       
      Thanks
       
      Andy
×
×
  • Create New...