-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathdynamic-orchestra-example.js
More file actions
62 lines (60 loc) · 1.81 KB
/
Copy pathdynamic-orchestra-example.js
File metadata and controls
62 lines (60 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import React from 'react';
import { Orchestra } from '../../../src/';
const midiURL = 'https://s3-eu-west-1.amazonaws.com/ut-music-player/assets/midis/beet1track-medium-fast.mid';
class StaticOrchestraExample extends React.Component {
constructor(props) {
super(props);
this.state = {
playSong: true,
};
this.onMidiLoaded = this.onMidiLoaded.bind(this);
this.onInstrumentsReady = this.onInstrumentsReady.bind(this);
this.togglePlayback = this.togglePlayback.bind(this);
}
componentDidMount() {
}
//eslint-disable-next-line
onMidiLoaded(parsedMidi) {
console.warn(`Midi loaded ${JSON.stringify(parsedMidi, 2, 2)}. Loading instruments now ...`);
return parsedMidi;
}
onInstrumentsReady(instruments) {
this.setState({ play: true });
return instruments;
}
//eslint-disable-next-line
onNotePlayed(noteName) {
console.warn(`Note ${noteName} was played, optionally handle this event`);
}
togglePlayback() {
this.setState({ play: !this.state.play });
}
renderNote(instrumentName, noteName) {
return (
<div className="control">
<div className={`button ${this.state.playC ? 'is-primary' : ''}`}>
Note : {instrumentName} {noteName}
</div>
</div>
);
}
render() {
return (
<div>
<Orchestra
midiURL={midiURL}
onMidiLoaded={this.onMidiLoaded}
onInstrumentsReady={this.onInstrumentsReady}
play={this.state.playSong}
selectedTracks={[0]}
onNotePlayed={this.onNotePlayed}
renderNote={this.renderNote}
>
<div> This is an orchestra it can play complex melodies ! </div>
</Orchestra>
<button onClick={this.togglePlayback}>Toggle playback</button>
</div>
);
}
}
export default StaticOrchestraExample;