Online Sequencer Make music online
  • Sequences
  • Members
  • Chat
  • Forum
  • Wiki

Existing user? Sign In Create account
Login at Online Sequencer Forums

Online Sequencer Forums › Online Sequencer › Online Sequencer Discussion
« Previous 1 … 44 45 46 47 48 … 79 Next »

Useful Console Code Thread

Pages (3): « Previous 1 2 3 Next »
Thread tools
Useful Console Code Thread
korwynkim Offline
cat
16 Posts:
 
#11
10-16-2018, 09:56 PM
Hmm. That might end up working better than these
##909662 ##909646


Trophy: https://imgur.com/a/4B0juxZ
Reply
Jacob_ Offline
Administrator
343 Posts:
 
#12
10-16-2018, 10:03 PM
(10-16-2018, 09:30 PM)Frank Wrote:
(10-16-2018, 05:07 PM)blobertthebob Wrote:
(10-16-2018, 04:54 PM)Jacob_ Wrote:
Code:
loadInstrument(13);
var el = $('<input type="file" accept="audio/*">');
$(document.body).append(el);

el.on('change', function(e){
   var reader = new FileReader();
   reader.onload = function (e) {
       var context = new AudioContext();
       context.decodeAudioData(e.target.result, function(buffer){
           var node = context.createAnalyser();
           var resolution = 4;
           node.fftSize = 4096;
           node.smoothingTimeConstant = 0;
           var bufferLength = node.frequencyBinCount;
           var dataArray = new Uint8Array(bufferLength);
           var audioSource = context.createBufferSource();
           audioSource.buffer = buffer;
           audioSource.loop = false;
           audioSource.connect(node);
           var time = 0;
           audioSource.start(0);  
           setInterval(function(){
               node.getByteFrequencyData(dataArray);
               var f = [];
               for (var i = 1; i < dataArray.length - 1; i++) {
                 var isPeak = dataArray[i] >= dataArray[i-1] && dataArray[i] >= dataArray[i+1];
                 if (isPeak) {
                   f.push([i, dataArray[i]]);
                 }
               }
               f.sort(function(a, b){return b[1] - a[1]});
               for(var i = 0; i < Math.min(f.length, 4); i++) {
                 var frequency = f[i][0] * context.sampleRate / node.fftSize;
                 var note = piano[Math.round((piano.length*Math.log(2)+12*Math.log(55/frequency)+Math.log(4))/(Math.log(2)))];
                 if (note != undefined && f[i][1] > 32) {
                   song.addNote(new Note(song, note, time/resolution, 1/resolution, 13));
                 }
               }
               time++;
           }, song.sleepTime/resolution);
           setInterval(SequencerView.repaint, 1000);
       });
   }
   
   reader.readAsArrayBuffer(e.target.files[0]);
});

el.click();
this is dank

Agreed, I was considering doing something like this, but I thought it was impossible. Who knows, maybe I should try to outdo this.

The difficult part is converting a segment of audio to an array of frequency buckets, and that's completely handled by the Web Audio API. This could definitely be done better though, it just figures out the loudest 4 notes for each 1/16 interval and adds each one if the volume is above some arbitrary number.

If you put your programming knowledge to work at something more useful than stealing people's passwords you'd be surprised at what you can do. Smile When I was 13 I wrote a file management program that was used by a web hosting company all because I hacked the 14 year old owner's script in 30 seconds and wanted them to have something better. https://buildism.net/php


Reply
guest Offline
Member
454 Posts:
   
#13
10-16-2018, 10:19 PM
HOLY SHIZA


my soundcloud
Reply
Jacob_ Offline
Administrator
343 Posts:
 
#14
10-16-2018, 10:20 PM
(10-16-2018, 10:19 PM)Guest Wrote: HOLY SHIZA

yes


Reply
LucentTear Online
Somebody Who Does A Bit Of Everything
869 Posts:
 
#15
10-16-2018, 10:27 PM
(07-11-2018, 05:22 PM)Jacob_ Wrote: This will have a great impact on your creativity:


Code:
j = 0;
window.setInterval(function() {
    for (var i = 0; i < settings['numInstruments']; i++) {
        settings['instrumentColors'][i] = [Math.floor(Math.random() * 255), Math.floor(Math.random() * 255), Math.floor(Math.random() * 255)];
    };
    SequencerView.repaint();
    $('canvas').css('filter', 'blur(' + (Math.sin(j) * 8) + 'px)');
    j += 0.1;
}, 100);

What else can you come up with?


OS Super Secret Settings button when?


  • x1
    • x1
    • guest
Reply
guest Offline
Member
454 Posts:
   
#16
10-16-2018, 10:30 PM
adding these to the console commands doc


my soundcloud
Reply
Jacob_ Offline
Administrator
343 Posts:
 
#17
10-16-2018, 10:32 PM
super secret settings? console commands doc? I didn't know either was a thing


Reply
guest Offline
Member
454 Posts:
   
#18
10-16-2018, 10:33 PM
here you go jacob https://docs.google.com/document/d/1PBxf...sp=sharing


my soundcloud
Reply
Frank Offline
Grey Hat Script Kiddie who can Compose Music
388 Posts:
 
#19
10-17-2018, 07:07 PM
(10-16-2018, 10:32 PM)Jacob_ Wrote: super secret settings? console commands doc? I didn't know either was a thing

Jacob_ only plays Classic Minecraft CONFIRMED
seriously though, super secret settings is a modern MC easter egg if you didn't know.


Kim Wrote:##878337 + https://js-game.glitch.me + Doesnt take peopel serious if their has badly speling gramer puntuatin
Reply
Jacob_ Offline
Administrator
343 Posts:
 
#20
10-27-2018, 03:23 PM
Slightly improved, also put the parameters at the top so it's easier to adjust. Does anyone know how to remove the annoying high frequency noise?

Code:
var resolution = 4; // how many times to subdivide each 1/4 note, 4 means 1/16 notes
var fftSize = 8192; // must be power of 2
var maxNotes = 6; // maximum number of notes to add for each interval
var minIntensity = 96; // minimum volume for note to be added (0-255)

loadInstrument(13);
var el = $('<input type="file" accept="audio/*">');
$(document.body).append(el);

el.on('change', function(e){
  var reader = new FileReader();
  reader.onload = function (e) {
      var context = new AudioContext();
      context.decodeAudioData(e.target.result, function(buffer){
          var node = context.createAnalyser();
          node.fftSize = fftSize;
          node.smoothingTimeConstant = 0;
          node.maxDecibels = 0;
          var bufferLength = node.frequencyBinCount;
          var dataArray = new Uint8Array(bufferLength);
          var audioSource = context.createBufferSource();
          audioSource.buffer = buffer;
          audioSource.loop = false;
          audioSource.connect(node);
          var time = 0;
          audioSource.start(0);  
          setInterval(function(){
              node.getByteFrequencyData(dataArray);
              var f = [];
              for (var i = 1; i < dataArray.length - 1; i++) {
                var isPeak = dataArray[i] >= dataArray[i-1] && dataArray[i] >= dataArray[i+1];
                if (isPeak) {
                  f.push([i, dataArray[i]]);
                }
              }
              f.sort(function(a, b){return b[1] - a[1]});
              var i = 0;
              var added = 0;
              var s = "";    
              while (added < maxNotes) {
                var frequency = f[i][0] * context.sampleRate / node.fftSize;
                var note = piano[Math.round((piano.length*Math.log(2)+12*Math.log(55/frequency)+Math.log(4))/(Math.log(2)))];
                if (note != undefined && f[i][1] > minIntensity) {
                  song.addNote(new Note(song, note, time/resolution, 1/resolution, 13));
                  added++;
                  s += "[" + note + " " + f[i][1] + "] ";
                }
                i++;
                if (i >= f.length) {
                   break;
                }
              }
              console.log(s);
              time++;
          }, song.sleepTime/resolution);
          setInterval(SequencerView.repaint, 1000);
      });
  }
 
  reader.readAsArrayBuffer(e.target.files[0]);
});

el.click();


Reply
Pages (3): « Previous 1 2 3 Next »



Users browsing this thread:   1 Guest(s)


  •  Return to Top
  •  Contact Us
  •   Home
  •  Lite mode
© Rush Crafted with ❤ by iAndrew
Powered By MyBB, © 2002-2025 MyBB Group.
Linear Mode
Threaded Mode
View a Printable Version
Subscribe to this thread
Add Poll to this thread
Send thread to a friend