Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Midi spanner - give spanners the possibility of rendering midi CCs [WIP] #2722

Open
wants to merge 5 commits into
base: master
from

Conversation

Projects
None yet
@hpfmn
Copy link
Contributor

hpfmn commented Jul 5, 2016

This is a work in progress. Currently just the switch functionality is implemented. I like to discuss if the way I'm doing is good. Also I'm not 100% happy with the typedef names.

@hpfmn

This comment has been minimized.

Copy link
Contributor Author

hpfmn commented Jul 5, 2016

Now also continuous spanners are implemented

if (endTick == -1)
endTick = tick2;

int ticksPerMidiInc = s->ticks() / (s->ccEnd() - s->ccStart());

This comment has been minimized.

@hpfmn

hpfmn Jul 5, 2016

Author Contributor

not sure if that isn't accurate enough? We could also do floating point calculations and use ints at push_back?

// renderSpanners
//---------------------------------------------------------

void Score::renderSpanners(EventMap* events, int staffIdx)
{
midiCCMap CCEvents = midiCCMap();
foreach (const RepeatSegment* rs, *repeatList()) {

This comment has been minimized.

@Jojo-Schmitz

Jojo-Schmitz Jul 5, 2016

Contributor

while touching the code, this is a good opporunity to change to C++11 for (... : ...)

@Jojo-Schmitz

This comment has been minimized.

Copy link
Contributor

Jojo-Schmitz commented Jul 15, 2016

Seems a rebase is needed?

@hpfmn hpfmn force-pushed the hpfmn:MidiSpanner branch from ff77d56 to 5b59436 Jul 15, 2016

@hpfmn

This comment has been minimized.

Copy link
Contributor Author

hpfmn commented Jul 15, 2016

done ;)

@hpfmn hpfmn force-pushed the hpfmn:MidiSpanner branch from 464c3ae to b9b9740 Jul 15, 2016

@hpfmn hpfmn force-pushed the hpfmn:MidiSpanner branch 4 times, most recently from d000f1b to f2c93f6 Jul 29, 2016

@hpfmn hpfmn force-pushed the hpfmn:MidiSpanner branch 6 times, most recently from e378c46 to 1eed521 Aug 16, 2016

@RobFog

This comment has been minimized.

Copy link

RobFog commented Sep 30, 2016

Is this PR still WIP or does it just need a rebase to be merged?

@hpfmn hpfmn referenced this pull request Oct 4, 2016

Closed

Single Note Crescendo #2655

@hpfmn

This comment has been minimized.

Copy link
Contributor Author

hpfmn commented Oct 4, 2016

I'll try to work on a rebase later today!

@hpfmn hpfmn force-pushed the hpfmn:MidiSpanner branch from 9351c8a to 1415ba6 Oct 4, 2016

@hpfmn

This comment has been minimized.

Copy link
Contributor Author

hpfmn commented Oct 4, 2016

I guess there it could also use some work with the safe to score and save to default buttons - since they don't interact with soundbanks

EDIT: also having the possibility of issuing multiple midi events per spanner might be something to consider

@Jojo-Schmitz

This comment has been minimized.

Copy link
Contributor

Jojo-Schmitz commented Nov 16, 2016

Seems another rebase is needed

@bryhoyt

This comment has been minimized.

Copy link

bryhoyt commented Mar 26, 2017

I'm very keen to know the status of this one. I'm really looking forward to it being included in the main codebase. Is there anything holding it up that could use some additional help?

@lasconic

This comment has been minimized.

Copy link
Member

lasconic commented Feb 22, 2018

@bryhoyt just to be clear, this would completely break compatibility between release and we try to avoid this between bug fix releases. That's why this can't be put in 2.2.

@bryhoyt

This comment has been minimized.

Copy link

bryhoyt commented Feb 22, 2018

Thanks, can understand that.

@Inothernews1

This comment has been minimized.

Copy link

Inothernews1 commented Mar 12, 2018

Really hoping that this will be in 3.0, it's a powerful feature we've all been hoping for!! 👍👍👍

@ericfont

This comment has been minimized.

Copy link
Contributor

ericfont commented Mar 27, 2018

Sorry to bump, but can I assume this PR is closed?

In addition to allowing Spanners to control midi CC, I'd also like for sfz articulation to send midi CC to shape the attack.

@lasconic

This comment has been minimized.

Copy link
Member

lasconic commented Mar 27, 2018

We are in the middle of the release of 2.2 so I don't have much time.
PR is not closed. The approach here goes in the right direction. Sfz is not a spanner so it has nothing to do with this PR though. Sending MIDI CC is already possible on a staff text element (but not a dynamic...) if configured in instruments.xml. See the recent post about Hauptwerk organ here : https://musescore.org/en/node/270711

@ericfont

This comment has been minimized.

Copy link
Contributor

ericfont commented Mar 27, 2018

Thanks for clarifying. Sorry for getting you distracted, but the subject was just on my mind. I should inspect this PR later and see if I can learn more.

Sfz is still related to this PR. For one thing, sfz is most often at the start of a cresc, so I think care must be taken to make sure the implementations for sfz and cresc don't send conflicting CC messages. The page you linked to seems to only have one CC for a staff text, but a sfz (edit: sfp) would probably have a CC for loud expression at start of note and then momentarily followed by a CC for quiet.

@lgmventura

This comment has been minimized.

Copy link

lgmventura commented Aug 9, 2018

How is the current state of this? This should be between the highest priorities in the development of MuseScore, since the possibility of rendering midi CC opens new doors for future development and crescendo/diminuendo within single notes is a very basic and fundamental feature on playback, probably the most requested feature in the last years. Also single note pitch changes (continuous glissando) could be considered right afterwards.

@bryhoyt

This comment has been minimized.

Copy link

bryhoyt commented Aug 9, 2018

And in combination with the new support for filters in Zerberus, I could imagine some absolutely amazing things you could potentially do with this functionality.

@anatoly-os anatoly-os added the Priority label Sep 9, 2018

@Jojo-Schmitz

This comment has been minimized.

Copy link
Contributor

Jojo-Schmitz commented Nov 9, 2018

Any chance to get this into 3.0? Just got requested once again in https://musescore.org/en/node/277958
Unfortunatly lots of merge conflicts, so a rebase won't be simple

@alago197

This comment has been minimized.

Copy link

alago197 commented Nov 9, 2018

Any chance to get this into 3.0? Just got requested once again in https://musescore.org/en/node/277958
Unfortunatly lots of merge conflicts, so a rebase won't be simple

Hi,

I would like to suggest to start with a rebase but from the previous PR, #2655 , which was discarded for what seemed a more general approach at the time. As this PR 2722 seems to be much more complex, perhaps starting with that previous PR would be far easier to implement in the current code? I managed to build an old 3.0 dev (from the hpfmn's "CC11" branch) with that 2655 PR, and it worked fairly well.

@jthistle

This comment has been minimized.

Copy link
Contributor

jthistle commented Dec 9, 2018

it might be too much work, but I'd like to take a look at rebasing this possibly in time for 3 release. Or failing that, 3.1.

@jthistle

This comment has been minimized.

Copy link
Contributor

jthistle commented Dec 10, 2018

Or maybe not, after some advice from Marc. Perhaps it would be better to start from scratch using this and #2655 as 'inspiration'?

@alago197

This comment has been minimized.

Copy link

alago197 commented Dec 10, 2018

Or maybe not, after some advice from Marc. Perhaps it would be better to start from scratch using this and #2655 as 'inspiration'?

Hi there, @jthistle . Honestly, I'm not a profficient enough programmer to give the best opinion, but, given the complex funcionality introduced in this PR (Soundbanks, etc), and comparing them with the code in PR #2655, I would say that trying to rebase from the later would be easier. Specially the code in the first commit in this 2722 PR seems very complex (for me).

Sure this 2722 PR is the way to go, but between having nothing and trying to rebase from this, a half-way, interim view of attack this problem would be reviewing the former PR commits, one by one, and seeing if they fits with the current codebase without great pains.

@jthistle

This comment has been minimized.

Copy link
Contributor

jthistle commented Dec 10, 2018

Yes, I'd much rather rebase 200 lines of code, quickly, that I can understand well than rebase 2000 lines that I struggle to understand over a long period of time.

@alago197

This comment has been minimized.

Copy link

alago197 commented Dec 10, 2018

Yeah, easier.

Almost the only one problem I've encountered in hpfmn's 2655 PR is the following: if in a measure in a score having multiple staves/instruments, there are different note lengths, the playback of the new hairping markings over single note, when applied to these staves, get messed up. I know it's a serious problem with this PR but , alas, I don't know where to look in the PR code (maybe the problem is more profound) to correct or investigate.

I'm attaching here 2 scores written with the old 3.0 patched with PR 2655 (if you are interested, I've put this Windows build as a zip in https://drive.google.com/file/d/1xwn9fKo_sh4fBcb1lm_mGJxSNrodJbTm/view) that you can unzip in any folder (it will not mess your existing MuseScore installation).

You should open the below attached scores with this build, of course. Add in the Synthetiser the FluidR3_Mono or Musecore_General SF2 soundfonts (in fact PR 2655 worked just fine with any SF2 soundfonts I tried until now).

First score, "PR2655_test1_OK.mscx", plays well. It's a piece I wrote last year for testing the 2655 PR. You can hear the playback of the first bars as played inside this MuseScore in: https://clyp.it/tamsnoh4?token=ebccfd8812aea05708729ae7de8fd0c1 (test ok)

But in the second score, "PR2655_test1_NOT_OK_bar1.mscx", I altered the first measure, in the violas stave, changing the first half note for a dotted quarter. Doing so, the first stave's (violins) single-note hairpin plays "ppp" well until the "ff" marking (a first incorrect "leap" in the sound) - and after it, it fails too to play correctly the diminuendo hairpin that goes to the next measure: playback at https://clyp.it/claehgto?token=e3566cba4dc138f3e6b75ae6250e3c4b
(test not ok - check bars 1-2). It sustains the "ff" until the measure 2, where the violins start again from "pp". As you can hear, the "leap" is very noticiable - the diminuendo hairpin don't works in this scenario.

In any case, , I hope you find useful tis info, @jthistle .

PR2655_tests.zip

@jthistle

This comment has been minimized.

Copy link
Contributor

jthistle commented Dec 10, 2018

Thanks! For now I'm trying to rebase it; it's taken me about an hour to do 2/3 of it. I'll be surprised if it works without a lot of refactoring :/
Also, I can't guarantee anything - I'll try my best, but if it's taking too long or becomes way out of my depth, I'm afraid I might have to leave it.

@alago197

This comment has been minimized.

Copy link

alago197 commented Dec 11, 2018

@jthistle

This comment has been minimized.

Copy link
Contributor

jthistle commented Dec 11, 2018

Sorry, I deleted that because it turned out to not be finished. It is now, and it's kind of working.

https://github.com/jthistle/MuseScore/tree/rebase-hairpin-crescendo

@lgmventura

This comment has been minimized.

Copy link

lgmventura commented Dec 19, 2018

Wow, I tested here using the compilation for Windows through Wine on Linux and it worked very well! Thank you a lot!!! When is this going to the Master Branch? Are there still issues with it? Can someone explain the difference between both pull requests – the simpler approach and the more complex one –? I could try to give my tips according to my programming experiences.

@lgmventura

This comment has been minimized.

Copy link

lgmventura commented Dec 19, 2018

@alago197 How do I get the hairpin to work on single notes for other instruments I add and for other files? The option is only being shown in the example files you gave on both instruments there.

@jthistle

This comment has been minimized.

Copy link
Contributor

jthistle commented Dec 19, 2018

@lgmventura It's just a proof of concept thing. I'm working on a proper implementation with someone else at the moment who knows how MIDI and soundfonts work a lot better than I do. So, no, that exact code won't be going to master but we do hope to get a full version working that does the same thing :)

@alago197

This comment has been minimized.

Copy link

alago197 commented Dec 19, 2018

@alago197 How do I get the hairpin to work on single notes for other instruments I add and for other files? The option is only being shown in the example files you gave on both instruments there.

Hi,

If you are talking about using the hpfmn's 2655 MuseScore build I pointed above, you have to:

1.- Open the MusesScore program and first of all, activate the MIDI controls in Preferences (attached a screen capture)
2.- Create your score, with your instruments/staves. Open the Mixer and dial to the right the new velocity to volume wheels (attached a screen capture)
3.- Write your music and dynamics (p, mf, etc..) and, between them, put the hairpins as desired. If you have the Inspector opened at the time you put an hairpin, you will see there's a new checkbox , checked as default (screen attached)
4.- Save your score as a .mscx
5.- Edit (with WordPad for example) the .mscx, and locate the section you are interested.
In the .mscx samples I've describe above, I've used the Strings instrument.
6.- Insert the

   <dynamics>expression</dynamics>
   <fixedVelocity>127</fixedVelocity>

tags, below the "InstrumentId" tags

7.- Save your .mscx file with WordPad, and re-open it within MuseScore.

8.- Play it. You should see the single-note hairpins being played.

midi_controls
vel2vol_mixer_controls
hairpin_inspector


......

<Part>
  <Staff id="1">
    <StaffType group="pitched">
      <name>stdNormal</name>
      </StaffType>
    <bracket type="-1" span="0"/>
    </Staff>
  <trackName>Violines</trackName>
  <Instrument>
    <longName>Violines</longName>
    <shortName>Vlns.</shortName>
    <trackName>Violines</trackName>
    <minPitchP>55</minPitchP>
    <maxPitchP>103</maxPitchP>
    <minPitchA>55</minPitchA>
    <maxPitchA>88</maxPitchA>
    <instrumentId>strings.group</instrumentId>
    <dynamics>expression</dynamics>                              <===== hpfmn's new tags here
    <fixedVelocity>127</fixedVelocity>                               <=====     "  "   "
    <Articulation>
      <velocity>100</velocity>
      <gateTime>100</gateTime>
      </Articulation>
    <Articulation name="staccatissimo">
      <velocity>100</velocity>
      <gateTime>33</gateTime>
      </Articulation>
@lgmventura

This comment has been minimized.

Copy link

lgmventura commented Dec 19, 2018

Hi James, thanks for your answer. So, there are still issues to be resolved and points to be considered?! It would be really great to have another checkbox like "play hairpin on single note: change LPF cutoff frequency" for using in brass instruments, for example. It sounds a lot better if changing a low-pass filter cutoff frequency for certain instruments, but not for strings and some other instrument families. So it would be great to have both options. But I don't know well how MIDI and soundfonts could deal with it and how much work(around) would be necessary. Do you have a documentation on what you are actually doing?

@lgmventura

This comment has been minimized.

Copy link

lgmventura commented Dec 19, 2018

@alago197 Thanks a lot for your detailed explanation! I'll try it soon! :-)

@alago197

This comment has been minimized.

Copy link

alago197 commented Dec 19, 2018

@alago197 Thanks a lot for your detailed explanation! I'll try it soon! :-)

My pleasure. Another work I've done exclusively with hpfmn's work, almost "abusing" diminuendo/crescendo hairpins : https://clyp.it/ttxcnsiw?token=8ad2d1879babaa5b791349a38d3ecf4a .

@jthistle

This comment has been minimized.

Copy link
Contributor

jthistle commented Dec 19, 2018

@lgmventura I'm working on an entirely new way of implementing this along with S. Christian Collins, who's made many soundfonts and knows the ins and outs of midi and soundfonts. This new implementation will be 'inspired' by this pr, in a way, but will allow other ways of creating this affect, depending on which soundfont you're using :)

@lgmventura

This comment has been minimized.

Copy link

lgmventura commented Dec 20, 2018

Thank Alvaro @alago197 and James @jthistle ,
I've tested it here, it works pretty well when I give all the instruments the same variation in dynamics at the same time. However, if different instruments get different variations at the same time or even if there is another instrument playing anything while dynamics are being changed, it doesn't work, it just jumps from a dynamic to another. In the mixer, they're all assigned to different channels. I assume there must be some undesired coupling in the code. Or perhaps I have to give some different tag (like an ID) to each of them, like <dynamics>expression_1</dynamics> for the first instrument, <dynamics>expression_2</dynamics> for the second… or something like that?!
Thanks a lot, I'm really looking forward to seeing new results, especially this entirely new approach! ;-)

@alago197

This comment has been minimized.

Copy link

alago197 commented Dec 20, 2018

Thank Alvaro @alago197 and James @jthistle ,
I've tested it here, it works pretty well when I give all the instruments the same variation in dynamics at the same time. However, if different instruments get different variations at the same time or even if there is another instrument playing anything while dynamics are being changed, it doesn't work, it just jumps from a dynamic to another. In the mixer, they're all assigned to different channels. I assume there must be some undesired coupling in the code. Or perhaps I have to give some different tag (like an ID) to each of them, like <dynamics>expression_1</dynamics> for the first instrument, <dynamics>expression_2</dynamics> for the second… or something like that?!
Thanks a lot, I'm really looking forward to seeing new results, especially this entirely new approach! ;-)

Hi,

Again, if you refer to the hpfmn's build - yes, the problem you mention seems exactly the problem I described in #2722 (comment) . No, it's not related to having another "expression" tag, because that tag is fixed (see c0ca7dd#diff-7f889d8c5317780b684aa79a21a29625R219) . Frankly, I'm not capable to discover where the problem really lies in the code, though, and tried it. It seems not be related to note sound properties (ADSR) messed by the CC11 increments/decrements, but perhaps to the way measure events are collected in the new code, I don't know.

@jthistle

This comment has been minimized.

Copy link
Contributor

jthistle commented Jan 20, 2019

It's been a while since I've commented here. To let people know, I've added the single-note dynamic functionality in my PR #4541. I am constantly rebasing it with master to make sure it doesn't fall into the state that this PR has.

The target for merging my PR is before MuseScore 3.0.3 is released, failing that 3.0.4. All that is required is a soundfont update from S. Christian and any needed bugfixes, plus mtest fixes which I'm leaving until last.

An detailed explanation is attached to the PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.