1+ const Tone = require ( 'tone' ) ;
2+
3+ var drumCompress = new Tone . Compressor ( {
4+ "threshold" : - 12 ,
5+ "ratio" : 6 ,
6+ "attack" : 0.3 ,
7+ "release" : 0.1
8+ } ) . toMaster ( ) ;
9+
10+ var drum1 = new Tone . MembraneSynth ( {
11+ "pitchDecay" : 0.016 ,
12+ "octaves" : 2 ,
13+ "envelope" : {
14+ "attack" : 0.0006 ,
15+ "decay" : 0.5 ,
16+ "sustain" : 0
17+ }
18+ } ) . chain ( drumCompress ) ;
19+
20+
21+ var membranePart = new Tone . Sequence ( function ( time , pitch ) {
22+ drum1 . triggerAttack ( pitch , time , Math . random ( ) * 0.5 + 0.5 ) ;
23+ } , [ "F2" , 'F3' , "Eb3" , "C3" , null , "C3" , null , "Eb2" ] , "8n" ) . start ( 0 ) ;
24+ membranePart . loop = true ;
25+ membranePart . loopEnd = "1m" ;
26+
27+ var drum2 = new Tone . MembraneSynth ( {
28+ "pitchDecay" : 0.02 ,
29+ "octaves" : 10 ,
30+ "envelope" : {
31+ "attack" : 0.006 ,
32+ "decay" : 0.5 ,
33+ "sustain" : 0
34+ } ,
35+ "volume" : - 12
36+ } ) . chain ( drumCompress ) ;
37+
38+
39+ // var membranePart2 = new Tone.Sequence(function(time, pitch){
40+ // drum2.triggerAttack(pitch, time, Math.random()*0.5 + 0.5);
41+ // }, [null, 'D4', "Eb3", "Gb4", null, "C5", null, "Eb5", 'F5'], "16n").start(0);
42+ // membranePart2.loop = true;
43+ // membranePart2.loopEnd = "2n";
44+
45+
46+ var bell = new Tone . MetalSynth ( {
47+ "harmonicity" : 7 ,
48+ "resonance" : 400 ,
49+ "modulationIndex" : 10 ,
50+ "envelope" : {
51+ "decay" : 0.4 ,
52+ } ,
53+ "volume" : - 18
54+ } ) . toMaster ( ) ;
55+ var bellPart = new Tone . Sequence ( function ( time , freq ) {
56+ bell . frequency . setValueAtTime ( freq , time , Math . random ( ) * 0.3 + 0.3 ) ;
57+ bell . triggerAttack ( time ) ;
58+ } , [ 150 , null , 100 , null , 200 , 175 , null , 200 , null , 133 , null , 200 ] , "16t" ) . start ( 0 ) ;
59+
60+
61+ var bassPart = new Tone . Part ( function ( time , event ) {
62+ if ( Math . random ( ) < event . prob ) {
63+ drum2 . triggerAttackRelease ( event . note , event . dur , time ) ;
64+ }
65+ } , [
66+ { time : "0:0" , note : "C5" , dur : "4n + 8n" , prob : 1 } ,
67+ { time : "0:2" , note : "C5" , dur : "8n" , prob : 0.6 } ,
68+ { time : "0:2 + 4t" , note : "C5" , dur : "8n" , prob : 0.4 } ,
69+ { time : "0:2 + 4t*2" , note : "C5" , dur : "8n" , prob : 0.9 } ,
70+ { time : "1:0" , note : "C4" , dur : "4n + 8n" , prob : 1 } ,
71+ { time : "1:2" , note : "C5" , dur : "8n" , prob : 0.6 } ,
72+ { time : "1:2 + 4t" , note : "C5" , dur : "8n" , prob : 0.4 } ,
73+ { time : "1:2 + 4t*2" , note : "Eb5" , dur : "8n" , prob : 0.9 } ,
74+ { time : "2:0" , note : "F5" , dur : "4n + 8n" , prob : 1 } ,
75+ { time : "2:2" , note : "F5" , dur : "8n" , prob : 0.6 } ,
76+ { time : "2:2 + 4t" , note : "F4" , dur : "8n" , prob : 0.4 } ,
77+ { time : "2:2 + 4t*2" , note : "F5" , dur : "8n" , prob : 0.9 } ,
78+ { time : "3:0" , note : "F5" , dur : "4n + 8n" , prob : 1 } ,
79+ { time : "3:2" , note : "F4" , dur : "8n" , prob : 0.6 } ,
80+ { time : "3:2 + 4t" , note : "F5" , dur : "8n" , prob : 0.4 } ,
81+ { time : "3:2 + 4t*2" , note : "Bb4" , dur : "8n" , prob : 0.9 } ] ) . start ( 0 ) ;
82+
83+ bassPart . loop = true ;
84+ bassPart . loopEnd = "2m" ;
85+
86+ Tone . Transport . bpm . value = 72 ;
87+
88+ Tone . Transport . start ( "+0.1" )
0 commit comments