Skip to content

Latest commit

 

History

History
41 lines (29 loc) · 1.66 KB

README.md

File metadata and controls

41 lines (29 loc) · 1.66 KB

Musical-Instrument

Instrument methods to make them play music live in Pharo.
Musical instruments using Phausto.
Code instrumentation using OpenTelemetry-Pharo.

Installation

Metacello new
  githubUser: 'Gabriel-Darbord' project: 'Musical-Instrument' commitish: 'main' path: 'src';
  baseline: 'Musical';
  load

Installing Phausto requires additional steps, see on its wiki.

Usage

Playing Instruments

Concrete subclasses of MusicalInstrument each define an instrument that can play music using methods in the playing protocol. By default, the playMusicalInstrument message is sent to the class in which the instrumented method is installed. Re-implement this method to select which note or instrument is played by which class.

Instrumentation

To define an instrumentation to make target methods become musical, subclass OTMusicalInstrumentation, and use the OTMatcher class-side API to implement:

  • packageMatcher (any by default)
  • classMatcher (any by default)
  • methodMatcher

Redefine onMethodEnter: to add sampling, to decide when or what to play. The argument is an array containing an instance of the reified message send (RFMethodOperation) with the method, receiver, and arguments.

Examples

Try some of the provided instrumentations:

  • OTMusicalCollection plays a note on OrderedCollection >> #do:
  • OTMusicalException plays a sound file on a debugger that opens due to an exception.
  • OTMusicalGarbageCollector plays a note when a global garbage collection happens.