@@ -2934,6 +2934,22 @@ class Activity {
29342934 // note block to the active block.
29352935 this . blocks . activeBlock = this . blocks . blockList . length - 1 ;
29362936 } ;
2937+
2938+ //To create a sampler widget
2939+ this . makeSamplerWidget = ( sampleFile , sampleData ) => {
2940+ let samplerStack = [
2941+ [ 0 , "sampler" , 300 - this . blocksContainer . x , 300 - this . blocksContainer . y , [ null , 1 , 8 ] ] ,
2942+ [ 1 , "settimbre" , 0 , 0 , [ 0 , 2 , 6 , 7 ] ] ,
2943+ [ 2 , [ "customsample" , { value : [ "" , "" , "do" , 4 ] } ] , 0 , 0 , [ 1 , 3 , 4 , 5 ] ] ,
2944+ [ 3 , [ "audiofile" , { value : [ sampleFile . name , sampleData ] } ] , 0 , 0 , [ 2 ] ] ,
2945+ [ 4 , [ "solfege" , { value : "do" } ] , 0 , 0 , [ 2 ] ] ,
2946+ [ 5 , [ "number" , { value : 4 } ] , 0 , 0 , [ 2 ] ] ,
2947+ [ 6 , "vspace" , 0 , 0 , [ 1 , null ] ] ,
2948+ [ 7 , "hidden" , 0 , 0 , [ 1 , null ] ] ,
2949+ [ 8 , "hiddennoflow" , 0 , 0 , [ 0 , null ] ]
2950+ ] ;
2951+ return samplerStack ;
2952+ } ;
29372953
29382954 /*
29392955 * Handles keyboard shortcuts in MB
@@ -6483,6 +6499,9 @@ class Activity {
64836499 cleanData . match ( '<div class="code">(.+?)</div>' ) [ 1 ]
64846500 ) ;
64856501 }
6502+ else if ( files [ 0 ] . type === "audio/wav" ) {
6503+ obj = this . makeSamplerWidget ( files [ 0 ] , reader . result ) ;
6504+ }
64866505 else {
64876506 obj = JSON . parse ( cleanData ) ;
64886507 }
0 commit comments