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

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

Online Sequencer Forums › Off Topic › General Discussion
« Previous 1 … 13 14 15 16 17 … 56 Next »

NEW FREE Online Sequencer MELODY GENERATOR 2022 [NOT CLICKBAIT] [NO VIRUS]

Thread tools
NEW FREE Online Sequencer MELODY GENERATOR 2022 [NOT CLICKBAIT] [NO VIRUS]
pseudoname Away
prineside's worst PR agent
285 Posts:
   
#1
06-20-2022, 12:37 AM
hi. i went back and redid that melody generator i made a while back. heres the code
Code:
function generateMelody(keySignature = 'Minor', noteVarianceFactor = 30, octave = 5, note = 1, swing = false, beatCount = 16) {
  note = clamp(note, 1, 12) | 0;
  octave = clamp(octave, 2, 7) | 0;
  while (noteVarianceFactor < 10) noteVarianceFactor += 5;
  while (beatCount < 1) beatCount += 1;

  let noteDict;
  switch (keySignature) {
    case undefined: noteDict = settings.pianoNotes; break;
    case 'Major': noteDict = settings.scales[1].slice(0, 7); break;
    case 'Minor': noteDict = settings.scales[13].slice(0, 7); break;
    default: throw new Error("That's not a real key signature. Come on, man. You're better than this. (valid key signatures are 'Minor', 'Major', or undefined)")
  }

  let midTendencyFactor = [10, 7, 4, 0, -5, -10];
  let master = 'Online Sequencer:000000:'

  function createNote(time, pitch, length, ID) {
    master += `${time} ${pitch} ${length} ${ID};`
  }

  function randomlyShiftPitch() {
    let lowerBound = -noteVarianceFactor + midTendencyFactor[octave-2];
    let higherBound = noteVarianceFactor - midTendencyFactor[octave-2];
    let offset = Math.round(
      (Math.random() * (higherBound - lowerBound) + lowerBound) / 10
    );
    note += offset;
    while (note > noteDict.length) {
      if (octave == 7) {
        note = noteDict.length;
      } else {
        note -= noteDict.length
        octave += 1
      }
    }
    while (note < 1)
      if (octave == 2) {
        note = 1
      } else {
        note += noteDict.length
        octave -= 1
      }
  }
  const quarterBased = [[0, 2], [1, 3], [0, 1, 2], [0, 2, 3], 0, 2, [0, 3], null],
    thirdBased = [0, 8/3, [0, 8/3], [0, 4/3, 8/3]],
    riff = [
      [0, 1, 2, 3],
      [0, 1, 6/3, 8/3, 10/3],
      [0/3, 2/3, 4/3, 6/3, 8/3, 10/3],
      [0/3, 2/3, 4/3, 2, 3]
      // 0/3 and 6/3 are present so the triplets are clearer
    ],
    riffing = !swing;

  let beatCounter = 0, riffChancemaker = 0;
  function generateBeat() {
    let beatNotes = swing ? thirdBased[(Math.random() * thirdBased.length) | 0] : quarterBased[(Math.random() * quarterBased.length) | 0]
    if (beatNotes === null) {
      ++beatCounter;
      if (Math.round(Math.random())) riffChancemaker += Math.round(Math.random())
      if (riffChancemaker == 4) generateRiff();
      return;
    };
    if (typeof beatNotes == 'object') {
      for (let x of beatNotes) {
        randomlyShiftPitch(note, octave);
        let noteLength = ((x | 0) === x) ? 1 : 2/3;
        createNote(x + (beatCounter * 4), `${noteDict[note-1]}${octave}`, noteLength, 0)
      }
    } else {
      randomlyShiftPitch(note, octave)
      let noteLength = ((beatNotes | 0) === beatNotes) ? 1 : 2/3;
      createNote(beatNotes + (beatCounter * 4), `${noteDict[note-1]}${octave}`, noteLength, 0)
    }
    ++beatCounter;
    if (Math.round(Math.random())) riffChancemaker += Math.round(Math.random())
    if (riffChancemaker == 4) generateRiff();
  }

  function generateRiff() {
    if (!riffing) return;
    while (riffChancemaker > 0) {
      let beatNotes = riff[(Math.random() * riff.length) | 0];
      for (let x of beatNotes) {
        randomlyShiftPitch(note, octave)
        let noteLength = ((x | 0) === x) ? 1 : 2/3;
        createNote(x + (beatCounter * 4), `${noteDict[note-1]}${octave}`, noteLength, 0)
      }
      riffChancemaker -= 2
      beatCounter += 1
      if (riffChancemaker < 0) break
    }
  }

  while (beatCounter < beatCount) generateBeat();
  master += ':'
  return master
}
instead of python its in javascript now, so you can just go to the console in ur browser and paste this in
once you run the function, copy the output and paste it into the sequencer to hear the beautiful random melody

if you run into any issues, DM me


pseudoname
  • x2
  • x1
  • x1
    • x2
    • Cool172
    • Crumb
    • x1
    • Crumb
    • x1
    • Crumb
Reply
Crumb Offline
Banned
913 Posts:
   
#2
06-20-2022, 01:16 AM (This post was last modified: 06-20-2022, 01:20 AM by Crumb.)
no issues, works as always
- Crumthecrumb
⭐⭐⭐⭐⭐ 5/5

Review by customer from Online Sequencer.


Listen to my music
Now on https://bandlab.com/crumthecrumb
Reply
pseudoname Away
prineside's worst PR agent
285 Posts:
   
#3
06-20-2022, 09:41 AM
haha just kidding i made it betterer
Code:
function generateMelody(instr=instrument, swing=false, beatCount=16, keySignature='Minor', noteVarianceFactor=30, octave=5, note=1) {
  note = clamp(note, 1, 12) | 0;
  octave = clamp(octave, 2, 7) | 0;
  while (noteVarianceFactor < 10) noteVarianceFactor += 5;
  while (beatCount < 1) beatCount += 1;

  const notes = [];
  let noteDict;
  switch (keySignature) {
    case undefined: noteDict = settings.pianoNotes; break;
    case 'Major': noteDict = settings.scales[1].slice(0, 7); break;
    case 'Minor': noteDict = settings.scales[13].slice(0, 7); break;
    case 'play infinitode 2': noteDict = ['C', 'D#', 'F', 'G', 'A#']; break;
    default: throw new Error("That's not a real key signature. Come on, man. You're better than this. (valid key signatures are 'Minor', 'Major', or undefined)")
  }

  let midTendencyFactor = [10, 7, 4, 0, -5, -10];

  function createNote(time, pitch, length, ID) {
    notes.push(new Note(song, pitch, time, length, ID));
  }

  function randomlyShiftPitch() {
    let lowerBound = -noteVarianceFactor + midTendencyFactor[octave-2];
    let higherBound = noteVarianceFactor - midTendencyFactor[octave-2];
    let offset = Math.round(
      (Math.random() * (higherBound - lowerBound) + lowerBound) / 10
    );
    note += offset;
    while (note > noteDict.length) {
      if (octave == 7) {
        note = noteDict.length;
      } else {
        note -= noteDict.length
        octave += 1
      }
    }
    while (note < 1)
      if (octave == 2) {
        note = 1
      } else {
        note += noteDict.length
        octave -= 1
      }
  }
  const quarterBased = [[0, 2], [1, 3], [0, 1, 2], [0, 2, 3], 0, 2, [0, 3], null],
    thirdBased = [0, 8/3, [0, 8/3], [0, 4/3, 8/3]],
    riff = [
      [0, 1, 2, 3],
      [0, 1, 6/3, 8/3, 10/3],
      [0/3, 2/3, 4/3, 6/3, 8/3, 10/3],
      [0/3, 2/3, 4/3, 2, 3]
      // 0/3 and 6/3 are present so the triplets are clearer
    ],
    riffing = !swing;

  let beatCounter = 0, riffChancemaker = 0;
  function generateBeat() {
    let beatNotes = swing ? thirdBased[(Math.random() * thirdBased.length) | 0] : quarterBased[(Math.random() * quarterBased.length) | 0]
    if (beatNotes === null) {
      ++beatCounter;
      if (Math.round(Math.random())) riffChancemaker += Math.round(Math.random())
      if (riffChancemaker == 4) generateRiff();
      return;
    };
    if (typeof beatNotes == 'object') {
      for (let x of beatNotes) {
        randomlyShiftPitch(note, octave);
        let noteLength = ((x | 0) === x) ? 1 : 2/3;
        createNote(x + (beatCounter * 4), `${noteDict[note-1]}${octave}`, noteLength, instr)
      }
    } else {
      randomlyShiftPitch(note, octave)
      let noteLength = ((beatNotes | 0) === beatNotes) ? 1 : 2/3;
      createNote(beatNotes + (beatCounter * 4), `${noteDict[note-1]}${octave}`, noteLength, instr)
    }
    ++beatCounter;
    if (Math.round(Math.random())) riffChancemaker += Math.round(Math.random())
    if (riffChancemaker == 4) generateRiff();
  }

  function generateRiff() {
    if (!riffing) return;
    while (riffChancemaker > 0) {
      let beatNotes = riff[(Math.random() * riff.length) | 0];
      for (let x of beatNotes) {
        randomlyShiftPitch(note, octave)
        let noteLength = ((x | 0) === x) ? 1 : 2/3;
        createNote(x + (beatCounter * 4), `${noteDict[note-1]}${octave}`, noteLength, instr)
      }
      riffChancemaker -= 2
      beatCounter += 1
      if (riffChancemaker < 0) break
    }
  }

  while (beatCounter < beatCount) generateBeat();
  exec(() => {
      for(let note of notes) song.addNote(note);
      SequencerView.repaint();
  }, () => {
      for (let note of notes) song.removeNote(note);
      SequencerView.repaint();
  })
}
now it instantly inserts the new melody into the sequencer, and it supports undo
you can also make it whatever instrument you want
have fun


pseudoname
Reply
Ctrl Offline
belly button haver
139 Posts:
   
#4
06-28-2022, 01:01 PM
good shit


Ctrl™
Sequences
YouTube
Email - [email protected]

I'm always down to collab. Email me, pm me, or get my attention in chat! 
I do not have Discord anymore!
Reply
tbyunomi Offline
trapbeat349
1,366 Posts:
   
#5
06-28-2022, 05:02 PM
I'm not familiar with using the console

How do I use it and enter commands? (Sidenote I cant used Lucent's Guide because its blocked)


Reply
pseudoname Away
prineside's worst PR agent
285 Posts:
   
#6
07-03-2022, 06:36 PM
you just paste the code in and then afterward you can type generateMelody() to generate a melody


pseudoname
Reply
kae Offline
bals
150 Posts:
 
#7
01-27-2023, 10:59 AM
oh this is the good one?


hi    Blush Wink i like emoji 
Reply
Crumb Offline
Banned
913 Posts:
   
#8
01-28-2023, 03:07 AM
Yeah it's the newer one


Listen to my music
Now on https://bandlab.com/crumthecrumb
Reply



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