Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 : #ifndef MU_IMPORTEXPORT_ABSTRACTAUDIOWRITER_H
23 : #define MU_IMPORTEXPORT_ABSTRACTAUDIOWRITER_H
24 :
25 : #include "async/asyncable.h"
26 : #include "modularity/ioc.h"
27 : #include "audio/main/iplayback.h"
28 : #include "audio/main/istartaudiocontroller.h"
29 : #include "iaudioexportconfiguration.h"
30 : #include "project/iprojectsession.h"
31 : #include "playback/iplaybackcontroller.h"
32 : #include "global/iapplication.h"
33 :
34 : #include "project/inotationwriter.h"
35 :
36 : namespace mu::iex::audioexport {
37 : class AbstractAudioWriter : public project::INotationWriter, public muse::Contextable, public muse::async::Asyncable
38 : {
39 : public:
40 : muse::GlobalInject<IAudioExportConfiguration> configuration;
41 : muse::GlobalInject<muse::IApplication> application;
42 : muse::GlobalInject<muse::audio::IStartAudioController> startAudioController;
43 :
44 : public:
45 0 : AbstractAudioWriter(const muse::modularity::ContextPtr& iocCtx)
46 0 : : muse::Contextable(iocCtx) {}
47 :
48 : std::vector<UnitType> supportedUnitTypes() const override;
49 : bool supportsUnitType(UnitType unitType) const override;
50 :
51 : muse::Ret write(notation::INotationPtr notation, muse::io::IODevice& dstDevice, const Options& options = Options()) override;
52 : muse::Ret writeList(const notation::INotationPtrList& notations, muse::io::IODevice& dstDevice,
53 : const Options& options = Options()) override;
54 :
55 : muse::Progress* progress() override;
56 : void abort() override;
57 :
58 : protected:
59 : muse::Ret doWriteAndWait(notation::INotationPtr notation, muse::io::IODevice& dstDevice, const muse::audio::SoundTrackFormat& format,
60 : const Options& options = Options());
61 :
62 : private:
63 : void doWrite(muse::io::IODevice& dstDevice, const muse::audio::SoundTrackFormat& format);
64 :
65 : UnitType unitTypeFromOptions(const Options& options) const;
66 :
67 : muse::modularity::ContextPtr m_iocContext;
68 : muse::Progress m_progress;
69 : bool m_isCompleted = false;
70 : muse::Ret m_writeRet;
71 :
72 : notation::INotationPtr m_notationForRestore;
73 : };
74 : }
75 :
76 : #endif // MU_IMPORTEXPORT_ABSTRACTAUDIOWRITER_H
|