lmms
Cross-platform music production software
Toggle main menu visibility
Loading...
Searching...
No Matches
plugins
MidiImport
MidiImport.h
Go to the documentation of this file.
1
/*
2
* MidiImport.h - support for importing MIDI files
3
*
4
* Copyright (c) 2005-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5
*
6
* This file is part of LMMS - https://lmms.io
7
*
8
* This program is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU General Public
10
* License as published by the Free Software Foundation; either
11
* version 2 of the License, or (at your option) any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public
19
* License along with this program (see COPYING); if not, write to the
20
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21
* Boston, MA 02110-1301 USA.
22
*
23
*/
24
25
#ifndef _MIDI_IMPORT_H
26
#define _MIDI_IMPORT_H
27
28
#include <cstdint>
29
#include <QString>
30
31
#include "
MidiEvent.h
"
32
#include "
ImportFilter.h
"
33
34
namespace
lmms
35
{
36
37
38
class
MidiImport
:
public
ImportFilter
39
{
40
Q_OBJECT
41
public
:
42
MidiImport
(
const
QString&
file
);
43
~MidiImport
()
override
=
default
;
44
gui::PluginView
*
instantiateView
(QWidget*)
override
{
return
nullptr
; }
45
46
private
:
47
bool
tryImport
(
TrackContainer
* tc)
override
;
48
bool
readSMF
(
TrackContainer
* tc);
49
bool
readRIFF
(
TrackContainer
* tc);
50
bool
readTrack
(
int
track_end, QString& track_name);
51
void
error
();
52
53
inline
std::int32_t
read32LE
()
54
{
55
std::int32_t value =
readByte
();
56
value |=
readByte
() << 8;
57
value |=
readByte
() << 16;
58
value |=
readByte
() << 24;
59
return
value;
60
}
61
62
inline
std::int32_t
readVar
()
63
{
64
std::int32_t c =
readByte
();
65
std::int32_t value = c & 0x7f;
66
if
(c & 0x80)
67
{
68
c =
readByte
();
69
value = (value << 7) | (c & 0x7f);
70
if
(c & 0x80)
71
{
72
c =
readByte
();
73
value = (value << 7) | (c & 0x7f);
74
if
(c & 0x80)
75
{
76
c =
readByte
();
77
value = (value << 7) | c;
78
if
(c & 0x80) {
return
-1; }
79
}
80
}
81
}
82
return
!
file
().atEnd() ? value : -1;
83
}
84
85
inline
void
skip
(
unsigned
num_bytes) {
while
(num_bytes--) {
readByte
(); } }
86
87
int
m_timingDivision
= 0;
88
};
89
90
91
}
// namespace lmms
92
93
#endif
ImportFilter.h
MidiEvent.h
lmms::ImportFilter::ImportFilter
ImportFilter(const QString &_file_name, const Descriptor *_descriptor)
Definition
ImportFilter.cpp:41
lmms::ImportFilter::readByte
int readByte()
Definition
ImportFilter.h:69
lmms::ImportFilter::file
const QFile & file() const
Definition
ImportFilter.h:57
lmms::MidiImport::~MidiImport
~MidiImport() override=default
lmms::MidiImport::readVar
std::int32_t readVar()
Definition
MidiImport.h:62
lmms::MidiImport::error
void error()
Definition
MidiImport.cpp:627
lmms::MidiImport::instantiateView
gui::PluginView * instantiateView(QWidget *) override
Create a view for the model.
Definition
MidiImport.h:44
lmms::MidiImport::MidiImport
MidiImport(const QString &file)
Definition
MidiImport.cpp:86
lmms::MidiImport::skip
void skip(unsigned num_bytes)
Definition
MidiImport.h:85
lmms::MidiImport::tryImport
bool tryImport(TrackContainer *tc) override
Definition
MidiImport.cpp:91
lmms::MidiImport::readRIFF
bool readRIFF(TrackContainer *tc)
Definition
MidiImport.cpp:592
lmms::MidiImport::readSMF
bool readSMF(TrackContainer *tc)
Definition
MidiImport.cpp:274
lmms::MidiImport::read32LE
std::int32_t read32LE()
Definition
MidiImport.h:53
lmms::MidiImport::m_timingDivision
int m_timingDivision
Definition
MidiImport.h:87
lmms::MidiImport::readTrack
bool readTrack(int track_end, QString &track_name)
lmms::TrackContainer
Definition
TrackContainer.h:49
lmms::gui::PluginView
Definition
PluginView.h:36
lmms
Definition
RemotePluginBase.cpp:34
Generated on
for lmms by
1.18.0