musescore / MuseScore

MuseScore is an open source and free music notation software. For support, contribution, bug reports, visit MuseScore.org. Fork and make pull requests!
https://musescore.org
Other
12.17k stars 2.64k forks source link

Option to export selected measures to audio file #19345

Open Stccl opened 1 year ago

Stccl commented 1 year ago

Your idea

I'd love to be able to select specific measures before exporting my score to an audio file, so that only these measures are exported.

Problem to be solved

Right now, if you want to share a cool chord progression, or a specific part of a piece you're working on, you have to either export the whole score and trim the audio file in an audio software like audacity (which can take a long time for long scores or when there are a lot of instruments), or record your screen or PC audio.

Prior art

Most video editing apps allow you to add in and out markers, and export what's in between. I'm thinking of something like that.

Additional context

No response

XiaoMigros commented 1 year ago

Personally I think a simple 'Export Selection' button would be best, allowing to filter specific instruments too

Stccl commented 1 year ago

Personally I think a simple 'Export Selection' button would be best, allowing to filter specific instruments too

That's what I was thinking about actually!

MarcSabatella commented 1 year ago

There is already Edit / Save selection, although it's always been extremely buggy. It could make sense to move that functionality into a new Export selection command, with MSCZ just listed as one of the file types available.

XiaoMigros commented 1 year ago

We could probably get SVG and PNG too, exporting the selection as a rectangle from continuous view (not to mention mxl and midi)

vashutangri commented 1 year ago

Hey, this seems interesting. Would love to work on it!

Rohan-here commented 8 months ago

Is someone working on this task, if not I would like to work on this

HadrienG2 commented 8 months ago

@MarcSabatella I just came up across this need, and "save selection" works but is a bit clunky : if the person you want to share with doesn't have musescore at hand and needs audio you need to first save the selection, then open the new file, and finally export the result.

I like the way Audacity's export dialog handles this with the radio buttons at the bottom: image

Yelburissimo commented 6 months ago

Hello everyone! I'd like to start working on this issue if possible. Also stumbled upon the need for this feature recently

wizofaus commented 3 months ago

Would also like this, but it appears lots of people have already offered to work on it...

wizofaus commented 1 month ago

Given the lack of any actual PRs put up, and the fact it's a feature I want on a regular basis, I'll probably have a crack at this within the next few days.

BTW is the expectation that you only export the selected staves too? I.e. if you export selection, it should do the same as what hitting "play" does when there's a selection.

wizofaus commented 1 month ago

NB current PR doesn't work for MuseSounds if your selection is not from the start of the piece - it always exports from the beginning (but it does export the right duration!) But I can't easily debug why, because as soon as MuseSamplerCoreLib.dll is loaded while the debugger is attached, all threads just die and leaves a zombie process running. It works fine if the MuseSamplerCoreLib is not present and it only uses the fluid sequencer.

wizofaus commented 1 month ago

So...I figured out that was due to this code in MuseSamplerWrapper.cpp:

    if (currentRenderMode() == RenderMode::OfflineMode) {
        if (m_samplerLib->processOffline(m_sampler, m_bus) != ms_Result_OK) {
            return 0;
        }
    } else {
        if (m_samplerLib->process(m_sampler, m_bus, m_currentPosition) != ms_Result_OK) {
            return 0;
        }
    }

that basically means it ignores the current sequence position when rendering in offline mode, which is what's used for audio export. So I tried changing it to NOT use offline mode, and that produces no output at all. Given both processOffline and process are functions inside MuseSamplerCoreLib, I'm not really sure what else I can do about this. The only other option would be first creating an "extraction" of the notation that just captures the selected range, and initialising the playback engine with that instead, but how that would work with notes/events etc. that start before the selected range but extend into seems problematic. Or it might even be possible to accept that AbstractSynthesizer always produces for the whole score (or up to the end of the selection), then the resulting audio is processed to trim off the "unselected" portion, but the performance wouldn't be great.

Might have to hand what I've done so far over to the core team to work out a solution that will work with MuseSampler.

wizofaus commented 1 month ago

I found a workaround, which I'm not a big fan of but it seems to do the job, which is just to ask the MuseSamplerCoreLib to process events in offline mode until it's gone through enough samples to reach the current position, and simply discard that data. Have included in PR.

XiaoMigros commented 1 month ago

The linked PR doesn't address any of the comments in this thread though, right?

wizofaus commented 1 month ago

It allows exporting a selection to an audio file, which is what the feature request is...

XiaoMigros commented 1 month ago

That's not what I was asking...