Jump to content

dentpuzz

Member
  • Posts

    4
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

dentpuzz's Achievements

Newbie

Newbie (1/14)

  • First Post Rare
  • Reacting Well Rare
  • Conversation Starter Rare
  • Week One Done
  • One Month Later Rare

Recent Badges

8

Reputation

  1. There is, but it doesn't work in the same way. Update to add octave layer for a thicker, more realistic sound. //------------------------------------------------------------------------------ // Guitar Strummer 2.5 Dennis Caunce 2023. https://www.buymeacoffee.com/dentpuzz //------------------------------------------------------------------------------ // Set up keys to use here Next version will have UI var strumUpKey = 96; // Key to strum up (default: 96) var strumDownKey = 97; // Key to strum down (default: 97) var lowNote = 52; // Low note for the detection area var highNote = 94; // High note for the detection area // End of Set UI Section var strumSpeed = 100; // Strumming speed (default: 100 ms) var heldNotes = {}; // Object to store held notes var triggerVelocity = 0; // Velocity to use for strumming function HandleMIDI(e) { if (e instanceof NoteOn) { var note = e.pitch; var noteValue = parseInt(note); if (noteValue >= lowNote && noteValue <= highNote) { heldNotes[noteValue] = e.velocity; // Don't send the NoteOn events within the detection area return; } } else if (e instanceof NoteOff) { var note = e.pitch; var noteValue = parseInt(note); delete heldNotes[noteValue]; var octaveDown = GetParameter("Octave Down"); // Get the value of the "Octave Down" checkbox if (octaveDown) { var noteOffLower = new NoteOff; noteOffLower.pitch = noteValue + 12; // Transpose one octave down noteOffLower.sendAfterMilliseconds(0); } } if (e instanceof NoteOn && (e.pitch === strumUpKey || e.pitch === strumDownKey)) { e.trace("Strum key pressed: " + e.pitch); triggerVelocity = e.velocity; // Store the trigger key velocity strumChord(heldNotes, e.pitch); } if (e.send()) { // Let all other events pass through } } function strumChord(chord, strumKey) { var notes = Object.keys(chord).map(function (x) { return parseInt(x); }); var delay = 0; var strumSpeed = GetParameter("Strum Speed"); // Get the strum speed from the slider var octaveDown = GetParameter("Octave Down"); // Get the value of the "Octave Down" checkbox for (var i = 0; i < notes.length; i++) { var noteToPlay = new NoteOn; noteToPlay.pitch = notes; noteToPlay.velocity = triggerVelocity; noteToPlay.sendAfterMilliseconds(delay); delay += strumSpeed; if (octaveDown) { var noteLower = new NoteOn; noteLower.pitch = notes + 12; // Transpose one octave down noteLower.velocity = triggerVelocity; noteLower.sendAfterMilliseconds(delay); } } } var PluginParameters = [ { name: "Strum Speed", type: "lin", unit: "ms", minValue: 1, maxValue: 1000, numberOfSteps: 999, defaultValue: 8, }, { name: "Octave Down", type: "checkbox", defaultValue: 0, }, ];
  2. I found myself in need of a guitar strum so I wrote this. Play your chord within the detection area and use strum up and down key to perform the strum. velocity is set to how hard you hit the strum key, not the chord. If this helps, please consider buying me a coffee... //------------------------------------------------------------------------------ // Guitar Strummer 2. Dennis Caunce 2023. https://www.buymeacoffee.com/dentpuzz //------------------------------------------------------------------------------ //Set up keys to use here Next version will have UI var strumUpKey = 96; // Key to strum up (default: 96) var strumDownKey = 97; // Key to strum down (default: 97) var lowNote = 52; // Low note for the detection area var highNote = 94; // High note for the detection area //End of Set UI Section var strumSpeed = 100; // Strumming speed (default: 100 ms) var heldNotes = {}; // Object to store held notes var triggerVelocity = 0; // Velocity to use for strumming function HandleMIDI(e) { if (e instanceof NoteOn) { var note = e.pitch; var noteValue = parseInt(note); if (noteValue >= lowNote && noteValue <= highNote) { heldNotes[noteValue] = e.velocity; // Don't send the NoteOn events within the detection area return; } } else if (e instanceof NoteOff) { var note = e.pitch; var noteValue = parseInt(note); delete heldNotes[noteValue]; } if (e instanceof NoteOn && (e.pitch === strumUpKey || e.pitch === strumDownKey)) { e.trace("Strum key pressed: " + e.pitch); triggerVelocity = e.velocity; // Store the trigger key velocity strumChord(heldNotes, e.pitch); } if (e.send()) { // Let all other events pass through } } function strumChord(chord, strumKey) { var notes = Object.keys(chord).map(function (x) { return parseInt(x); }); var delay = 0; var strumSpeed = GetParameter("Strum Speed"); // Get the strum speed from the slider if (strumKey === strumUpKey) { notes.sort(function (a, b) { return a - b; }); } else if (strumKey === strumDownKey) { notes.sort(function (a, b) { return b - a; }); } for (var i = 0; i < notes.length; i++) { var noteToPlay = new NoteOn; noteToPlay.pitch = notes[i]; noteToPlay.velocity = triggerVelocity; // Set the strum velocity to the trigger key velocity noteToPlay.sendAfterMilliseconds(delay); delay += strumSpeed; } } var PluginParameters = [ { name: "Strum Speed", type: "lin", unit: "ms", minValue: 1, maxValue: 1000, numberOfSteps: 999, defaultValue: 8, }/*, { name: "Low Note", type: "lin", minValue: 21, maxValue: 106, numberOfSteps: 85, defaultValue: 52, }, { name: "High Note", type: "lin", minValue: 21, maxValue: 106, numberOfSteps: 85, defaultValue: 94, }, */ ];
  3. To use, hold down a chord and move the mod wheel. The notes you hold down will be arpeggiated up the keyboard. For a larger range, hold down lower notes. Velocity can be set using the slider or CC11 (expression pedal). If you find this script useful, a cup of coffee wouldn't go amiss... :-) //----------------------------------------------------------------------------- // Mod Wheel Harp Glissando // (c) 2023 Dennis Caunce // https://www.buymeacoffee.com/dentpuzz //----------------------------------------------------------------------------- var lastModWheelValue = -1; // Variable to store the last Mod Wheel value function HandleMIDI(e) { if (e instanceof NoteOn && e.velocity > 0) { var note = e.pitch; var noteValue = parseInt(note); heldNotes[noteValue] = e.velocity; // Include all versions of this note (12 notes apart) for (var i = 0; i <= 108 - noteValue; i += 12) { heldNotes[noteValue + i] = e.velocity; } } else if (e instanceof NoteOff) { var note = e.pitch; var noteValue = parseInt(note); delete heldNotes[noteValue]; // Remove all versions of this note (12 notes apart) for (var i = 0; i <= 108 - noteValue; i += 12) { delete heldNotes[noteValue + i]; } } if (e instanceof ControlChange) { if (e.number == 1) { // Map CC1 (Mod Wheel) values (0-127) to MIDI note values (21-108) var modWheelValue = Math.round(e.value * 0.85) + 21; if (modWheelValue != lastModWheelValue) { // Play notes only if the Mod Wheel value has changed for (var note in heldNotes) { var noteValue = parseInt(note); var noteInRange = (noteValue >= Math.min(lastModWheelValue, modWheelValue) && noteValue <= Math.max(lastModWheelValue, modWheelValue)); if (!notePlayed[note] && noteInRange) { var noteOn = new NoteOn; noteOn.pitch = noteValue; noteOn.velocity = GetParameter("Note Velocity"); noteOn.send(); var noteOff = new NoteOff(noteOn); noteOff.sendAfterMilliseconds(GetParameter("Note Length") + 0.1); notePlayed[note] = true; // Mark the note as played } else if (!noteInRange) { notePlayed[note] = false; // Reset notePlayed for notes out of range } } lastModWheelValue = modWheelValue; // Update the last Mod Wheel value } } else if (e.number == 64) { // Pass through CC64 (sustain) messages without modification e.send(); } else if (e.number == 11) { // Update the "Note Velocity" parameter with the CC11 value SetParameter("Note Velocity", e.value); } } e.trace(); // Print incoming MIDI messages for debugging } var heldNotes = {}; // Object to store held notes and their associated Mod Wheel values var notePlayed = {}; // Object to track played notes var PluginParameters = [ {name: "Note Velocity", type: "lin", minValue: 1, maxValue: 127, numberOfSteps: 126, defaultValue: 80}, {name: "Note Length", type: "lin", unit: "ms", minValue: 0.0, maxValue: 500.0, numberOfSteps: 100, defaultValue: 100.0} ];
  4. Can you share these again? The link isn't working for me. Thanks!
×
×
  • Create New...