paulrosen / abcjs

javascript for rendering abc music notation
Other
1.92k stars 283 forks source link

Feature Request: audio parameter for the "chords" instrument? #888

Closed deusoz closed 1 year ago

deusoz commented 1 year ago

Feature request How hard to get another parameter for the instrument used by "chords" I found it in the code and can have fun manually tweaking the value there,, so why not,, it would be a adding a nice and very substantial dimension to the playback prowess.

paulrosen commented 1 year ago

Is what you want to tweak covered by one of the %%MIDI commands described here? https://abcmidi.sourceforge.io/#gchord It's possible what you want to do has been described but isn't implemented yet.

In any case, can you describe a little bit more what you are trying to do? I'm not sure what stage of the sound production you are interested in. It could be during the mapping of what notes go where, it could be in the details of the volume or the length of the notes, or perhaps some other thing.

deusoz commented 1 year ago

wow, no, on the document, first time seeing that. Do ANY of those MIDI functions work with your Javascript?

AS for what I'm looking for. I can do better than describe it, I've already did my own "hack" . There's a certain line in your javascript file that gives the voice of the chords. I simply made that a variable. LINE 11057 var chordInstrument = ChordInsurgent; //herebe the chordinstrument var drumInstrument = 128; Then send it in as a global that defaults to 1, and can be set using 2nd parameter after "qp" Here I've implemented from your examples the instrument switcher, the playback controls, with on/off for chords and a GET type parameter with CodeIgniter to supply the chord voice ... I just did this just now to answer your question, so there's no mention of it yet. This link plays my choice of bagpipe for this tune that can be changed with the instrument selector using the audio parameters, as well as chords on/off using audio params, by default with the Accoustic Piano playing chords https://melodypedia.com/home/qp/91/ NOW here it uses the electric_piano_2 (program #5) but needs a complete page refresh; does not use audio params https://melodypedia.com/home/qp/91/5

Request is to add an audio param for that line 11057 "chordInstrument"

deusoz commented 1 year ago

So now I have your javascript able to play my two select voices. It's awesome! Incredible...

HEY the next logical step... How to configure the playback so separate voices are assigned to different synth programs? Haven't explored that one yet, but that's on my list.

paulrosen commented 1 year ago

That is possible with the %%MIDI commands. Put them just before each voice.

I'll do another pass on seeing which of the MIDI commands I can implement without slowing down the next release. I'm trying to get that out by the end of March.

deusoz commented 1 year ago

Hiya Paul,

I'm very excited and have to tell you right away.. I fixed the grace notes midi playback.

Grace notes.. even considering them to be up to 1/2 the size of the main note is way to big.. they hardly exist.. but the MAIN thing is they always come before the main note .. they should never push the main note off it's position forward . that was completely messing up playback for any passage with grace notes.

So I was just tinkering around.. I removed the "shift" of the start main note to accomodate for the grace notes, and then reversed the way the start happens shifting the backwards instead fo forward and also reducing the lengths and with some cockamamie numbers, I just come up with stuff, not by formula but by guesswork, the main thing is it's 200% better now.. so  to see what I mean, check out this Bulgarian piece how it plays on my site now, and take the abc and drop into your player and compare...  

I just have a non-minified version of the abc-basic on the site you can download, you can search "SSEDIT" for where I did stuff.. but ignore anything about trills, I have to fix those next,, I've just disabled them on this player, only pay attention to the grace note code changes, just a few lines and listen to the results... that "Tango Accordion" is one of my favorites with "dulcimer" doing the chords.  https://melodypedia.com/home/qp/19/15

 

BEst regards,

Stuart

paulrosen commented 1 year ago

Wow! That is amazing. It sounds great.

Grace notes vary in different styles of music so there probably needs to be a setting about how long the grace notes are and where they are placed.

deusoz commented 1 year ago

HI Paul, IMO, NO.... grace notes are grace notes, always come before the note is my experience. I played violin off broadway in NYC, 30+ years in professional Celtic and Italian folk music bands, volunteer orchestras doing classical music, plus I am adept at Slavic, Greek and Middle Eastern folk styles.. for all of that there is no variation on duration or where grace notes belong. Mordents, turns, trills, etc.. they extend beyond the beat, but a grace note should be complete BEFORE the beat... is my humble opinion. I think I have it set quite well now,, maybe the grace notes could be just a smidjin longer, or a very tiny smidgin more set "back" in time.

deusoz commented 1 year ago

This here, is a classical piece with grace notes, and they almost sound like a slight trill, so this tells me they need to go back in time just a smidjin more as they are (maybe?) conflicting slightly with the main note. https://melodypedia.com/home/qp/186 I'll look at that later and if I arrive at a better adjustment I will send you my code. (afterthought, this trilly sound here may be due to the synth voice envelope)

deusoz commented 1 year ago

HOWEVER,,, with Irish rolls, sometimes indicated with grace notes. .. those are not normal grace notes, it's just the best way we have to show what is happening.. With Celtic music rolls the graces notes as they show in scores sometimes, more or less represents a slight "cut" in the sound using the notes lower and higher than pitch,, to achieve a triplet effect.. this comes from bagpipe technique as a bagpiper cannot "blow" a triplet, so he has to affect it with quick finger snap cuts,,.. so these are not normal grace notes,, but our best approximation of how it should sound. https://melodypedia.com/home/qp/109

deusoz commented 1 year ago

UPDATE!! As it turns out,, I was at first trying to fix grace notes with the duration, but the durations were fine the way you had it, so I've removed any duration changes that I had made. DO THIS, to make it play grace notes better: 1) "shift forward" of the main note, and 2) removed the velocity decrease, and 3) changed the start of the grace notes to be NEGATIVE.. the duration is unchanged..

commented out lines 1729 to 1732

// if (elem.gracenotes) { // p.duration = p.duration; //SSEDIT .. commenting out the start offset // p.start = p.start + p.duration; // }

REMOVE any velocity decrease line 1653 if (elem.elem) elem.elem.midiGraceNotePitches = writeGraceNotes(graces, timeToRealTime(elem.time), velocity, currentInstrument); //SSEDIT // if (elem.elem) elem.elem.midiGraceNotePitches = writeGraceNotes(graces, timeToRealTime(elem.time), velocity * 1 / 3, currentInstrument); // make the graces a little quieter.

Shift back the grace notes LINE 1881 I only added the - before the = start -= gp.duration;//SSEDIT make this NEGATIVE

deusoz commented 1 year ago

that all being said however, I'm not testing on all possibilities,, not sure if that duration might go up to 1/2 of the note it precedes, I think that's what is happening,, however, a grace note should always be the equivalent of say a 1/32 note .. or less if lots of them .. no matter what note it precedes, even if a whole note, they should still be tiny little notes,, as if the person was making a mistake.. oops,, I meant this note when they arrive at the main note.. is one way of looking at it.

paulrosen commented 1 year ago

I think the original issue is resolved in 6.2.0. - %%MIDI bassprog, %%MIDI bassvol, %%MIDI chordprog, %%MIDI chordvol are now all implemented.