Comparing version 0.1.4-dev.d9459a2 to 0.1.4-dev.ff9e506
{ | ||
"name": "dittytoy", | ||
"version": "0.1.4-dev.d9459a2", | ||
"version": "0.1.4-dev.ff9e506", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
# Dittytoy | ||
This is a powerful package that allows you to compile and play code (ditties) from [Dittytoy.net](https://dittytoy.net), | ||
an online platform that allows you to create generative music using a minimalistic javascript API. | ||
Compile and play code (ditties) from [Dittytoy.net](https://dittytoy.net), an online platform that allows you to create generative music using a minimalistic javascript API. | ||
@@ -50,3 +49,3 @@ The API syntax of Dittytoy is loosely based on the syntax of [Sonic Pi](https://sonic-pi.net/tutorial.html). You can find the | ||
Note: most browsers only allow audio to be played after a user interaction. You should use the `play` method to start the | ||
Note: Most browsers only allow audio after a user interacts with it. You should use the `play` method to start the | ||
audio after a user interaction. | ||
@@ -67,6 +66,6 @@ | ||
Dittytoy emits events that you can listen to by subscribing to the `addEventListener` method. | ||
Dittytoy emits events you can listen to by subscribing to the `addListener` method. | ||
```ts | ||
dittytoy.addEventListener(MSG_PLAY, () => { | ||
dittytoy.addListener(MSG_PLAY, () => { | ||
console.log('Dittytoy starts playing'); | ||
@@ -81,7 +80,7 @@ }); | ||
```ts | ||
dittytoy.addEventListener(MSG_LOG, (data: any) => { | ||
dittytoy.addListener(MSG_LOG, (data: any) => { | ||
console.log(data.message); | ||
}); | ||
dittytoy.addEventListener(MSG_ERROR, (data: any) => { | ||
dittytoy.addListener(MSG_ERROR, (data: any) => { | ||
console.error(data.message); | ||
@@ -94,3 +93,3 @@ }); | ||
```ts | ||
dittytoy.addEventListener(MSG_INIT, (data:any) => { | ||
dittytoy.addListener(MSG_INIT, (data:any) => { | ||
console.log('Dittytoy is initialized, ready to play'); | ||
@@ -105,3 +104,3 @@ console.log('Structure of compiled ditty:', data.structure); | ||
```ts | ||
dittytoy.addEventListener(MSG_NOTE_PLAYED, (data:any) => { | ||
dittytoy.addListener(MSG_NOTE_PLAYED, (data:any) => { | ||
console.log(`♪ tick: ${data.tick.toFixed(3)}, note: ${data.note} (${data.loop}.${data.synth})`); | ||
@@ -121,12 +120,12 @@ }); | ||
```ts | ||
dittytoy.addEventListener(MSG_PLAY, () => { | ||
dittytoy.addListener(MSG_PLAY, () => { | ||
console.log('play'); | ||
}); | ||
dittytoy.addEventListener(MSG_PAUSE, () => { | ||
dittytoy.addListener(MSG_PAUSE, () => { | ||
console.log('pause'); | ||
}); | ||
dittytoy.addEventListener(MSG_STOP, () => { | ||
dittytoy.addListener(MSG_STOP, () => { | ||
console.log('stop'); | ||
}); | ||
dittytoy.addEventListener(MSG_RESUME, () => { | ||
dittytoy.addListener(MSG_RESUME, () => { | ||
console.log('resume'); | ||
@@ -133,0 +132,0 @@ }); |
161207
157