Merge branch 'stable-1.2'
This commit is contained in:
@@ -30,7 +30,7 @@ SET(PROJECT_COPYRIGHT "2008-${PROJECT_YEAR} ${PROJECT_AUTHOR}")
|
||||
SET(VERSION_MAJOR "1")
|
||||
SET(VERSION_MINOR "2")
|
||||
SET(VERSION_RELEASE "0")
|
||||
SET(VERSION_STAGE "rc3")
|
||||
SET(VERSION_STAGE "rc4")
|
||||
SET(VERSION_BUILD "0")
|
||||
SET(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_RELEASE}")
|
||||
IF(VERSION_STAGE)
|
||||
|
||||
@@ -32,7 +32,7 @@ Features
|
||||
* Many powerful instrument and effect-plugins out of the box
|
||||
* Full user-defined track-based automation and computer-controlled automation sources
|
||||
* Compatible with many standards such as SoundFont2, VST(i), LADSPA, GUS Patches, and full MIDI support
|
||||
* MIDI file importing
|
||||
* MIDI file importing and exporting
|
||||
|
||||
Building
|
||||
---------
|
||||
|
||||
@@ -143,6 +143,8 @@
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<string>True</string>
|
||||
</dict>
|
||||
|
||||
@@ -10,7 +10,7 @@ Comment[ca]=Producció fàcil de música per a tothom!
|
||||
Comment[fr]=Production facile de musique pour tout le monde !
|
||||
Comment[pl]=Prosta produkcja muzyki dla każdego!
|
||||
Icon=lmms
|
||||
Exec=env QT_X11_NO_NATIVE_MENUBAR=1 lmms %f
|
||||
Exec=env QT_X11_NO_NATIVE_MENUBAR=1 QT_AUTO_SCREEN_SCALE_FACTOR=1 lmms %f
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=Qt;AudioVideo;Audio;Midi;
|
||||
|
||||
@@ -30,9 +30,6 @@
|
||||
#include "export.h"
|
||||
#include "lmms_basics.h"
|
||||
|
||||
const int BM_INITIAL_BUFFERS = 512;
|
||||
//const int BM_INCREMENT = 64;
|
||||
|
||||
class EXPORT BufferManager
|
||||
{
|
||||
public:
|
||||
@@ -46,17 +43,6 @@ public:
|
||||
const f_cnt_t offset = 0 );
|
||||
#endif
|
||||
static void release( sampleFrame * buf );
|
||||
static void refresh();
|
||||
// static void extend( int c );
|
||||
|
||||
private:
|
||||
static sampleFrame ** s_available;
|
||||
static AtomicInt s_availableIndex;
|
||||
|
||||
static sampleFrame ** s_released;
|
||||
static AtomicInt s_releasedIndex;
|
||||
// static QReadWriteLock s_mutex;
|
||||
static int s_size;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -39,7 +39,9 @@ public:
|
||||
virtual ~ExportFilter() {}
|
||||
|
||||
|
||||
virtual bool tryExport( const TrackContainer::TrackList &tracks, int tempo, const QString &filename ) = 0;
|
||||
virtual bool tryExport(const TrackContainer::TrackList &tracks,
|
||||
const TrackContainer::TrackList &tracksBB,
|
||||
int tempo, int masterPitch, const QString &filename ) = 0;
|
||||
protected:
|
||||
|
||||
virtual void saveSettings( QDomDocument &, QDomElement & )
|
||||
|
||||
@@ -237,6 +237,7 @@ private:
|
||||
MidiPort m_midiPort;
|
||||
|
||||
NotePlayHandle* m_notes[NumKeys];
|
||||
NotePlayHandleList m_sustainedNotes;
|
||||
|
||||
int m_runningMidiNotes[NumKeys];
|
||||
QMutex m_midiNotesMutex;
|
||||
|
||||
@@ -25,13 +25,22 @@
|
||||
#ifndef MAINAPPLICATION_H
|
||||
#define MAINAPPLICATION_H
|
||||
|
||||
#include "lmmsconfig.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#ifdef LMMS_BUILD_WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
class MainApplication : public QApplication
|
||||
{
|
||||
public:
|
||||
MainApplication(int& argc, char** argv);
|
||||
bool event(QEvent* event);
|
||||
#ifdef LMMS_BUILD_WIN32
|
||||
bool winEventFilter(MSG* msg, long* result);
|
||||
#endif
|
||||
inline QString& queuedFile()
|
||||
{
|
||||
return m_queuedFile;
|
||||
|
||||
@@ -249,11 +249,4 @@ signals:
|
||||
|
||||
} ;
|
||||
|
||||
class AutoSaveThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
void run();
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
class MemoryHelper {
|
||||
public:
|
||||
|
||||
static void* alignedMalloc( int );
|
||||
static void* alignedMalloc( size_t );
|
||||
|
||||
static void alignedFree( void* );
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ struct MemoryPool
|
||||
{
|
||||
void * m_pool;
|
||||
char * m_free;
|
||||
int m_chunks;
|
||||
size_t m_chunks;
|
||||
QMutex m_mutex;
|
||||
|
||||
MemoryPool() :
|
||||
@@ -51,10 +51,10 @@ struct MemoryPool
|
||||
m_chunks( 0 )
|
||||
{}
|
||||
|
||||
MemoryPool( int chunks ) :
|
||||
MemoryPool( size_t chunks ) :
|
||||
m_chunks( chunks )
|
||||
{
|
||||
m_free = (char*) MemoryHelper::alignedMalloc( chunks );
|
||||
m_free = reinterpret_cast<char*>( MemoryHelper::alignedMalloc( chunks ) );
|
||||
memset( m_free, 1, chunks );
|
||||
}
|
||||
|
||||
@@ -103,6 +103,25 @@ private:
|
||||
static QMutex s_pointerMutex;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct MmAllocator
|
||||
{
|
||||
typedef T value_type;
|
||||
template<class U> struct rebind { typedef MmAllocator<U> other; };
|
||||
|
||||
T* allocate( std::size_t n )
|
||||
{
|
||||
return reinterpret_cast<T*>( MemoryManager::alloc( sizeof(T) * n ) );
|
||||
}
|
||||
|
||||
void deallocate( T* p, std::size_t )
|
||||
{
|
||||
MemoryManager::free( p );
|
||||
}
|
||||
|
||||
typedef std::vector<T, MmAllocator<T> > vector;
|
||||
};
|
||||
|
||||
|
||||
#define MM_OPERATORS \
|
||||
public: \
|
||||
@@ -124,7 +143,7 @@ static void operator delete[] ( void * ptr ) \
|
||||
}
|
||||
|
||||
// for use in cases where overriding new/delete isn't a possibility
|
||||
#define MM_ALLOC( type, count ) (type*) MemoryManager::alloc( sizeof( type ) * count )
|
||||
#define MM_ALLOC( type, count ) reinterpret_cast<type*>( MemoryManager::alloc( sizeof( type ) * count ) )
|
||||
// and just for symmetry...
|
||||
#define MM_FREE( ptr ) MemoryManager::free( ptr )
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QMutex>
|
||||
|
||||
#include "MemoryManager.h"
|
||||
|
||||
#include "ThreadableJob.h"
|
||||
#include "lmms_basics.h"
|
||||
|
||||
@@ -142,20 +144,17 @@ public:
|
||||
|
||||
void releaseBuffer();
|
||||
|
||||
sampleFrame * buffer()
|
||||
{
|
||||
return m_playHandleBuffer;
|
||||
}
|
||||
sampleFrame * buffer();
|
||||
|
||||
private:
|
||||
Type m_type;
|
||||
f_cnt_t m_offset;
|
||||
QThread* m_affinity;
|
||||
QMutex m_processingLock;
|
||||
sampleFrame * m_playHandleBuffer;
|
||||
sampleFrame* m_playHandleBuffer;
|
||||
bool m_bufferReleased;
|
||||
bool m_usesBuffer;
|
||||
AudioPort * m_audioPort;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
@@ -621,6 +621,11 @@ public:
|
||||
fetchAndProcessNextMessage();
|
||||
}
|
||||
}
|
||||
|
||||
static bool isMainThreadWaiting()
|
||||
{
|
||||
return waitDepthCounter() > 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual bool processMessage( const message & _m ) = 0;
|
||||
@@ -657,6 +662,14 @@ protected:
|
||||
|
||||
|
||||
private:
|
||||
#ifndef BUILD_REMOTE_PLUGIN_CLIENT
|
||||
static int & waitDepthCounter()
|
||||
{
|
||||
static int waitDepth = 0;
|
||||
return waitDepth;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SYNC_WITH_SHM_FIFO
|
||||
shmFifo * m_in;
|
||||
shmFifo * m_out;
|
||||
@@ -1089,6 +1102,26 @@ RemotePluginBase::message RemotePluginBase::waitForMessage(
|
||||
_busy_waiting = QThread::currentThread() ==
|
||||
QCoreApplication::instance()->thread();
|
||||
}
|
||||
|
||||
struct WaitDepthCounter
|
||||
{
|
||||
WaitDepthCounter( int & depth, bool busy ) :
|
||||
m_depth( depth ),
|
||||
m_busy( busy )
|
||||
{
|
||||
if( m_busy ) { ++m_depth; }
|
||||
}
|
||||
|
||||
~WaitDepthCounter()
|
||||
{
|
||||
if( m_busy ) { --m_depth; }
|
||||
}
|
||||
|
||||
int & m_depth;
|
||||
bool m_busy;
|
||||
};
|
||||
|
||||
WaitDepthCounter wdc( waitDepthCounter(), _busy_waiting );
|
||||
#endif
|
||||
while( !isInvalid() )
|
||||
{
|
||||
|
||||
@@ -101,6 +101,7 @@ const int effEditOpen = 14;
|
||||
const int effEditClose = 15;
|
||||
const int effEditIdle = 19;
|
||||
const int effEditTop = 20;
|
||||
const int effSetChunk = 24;
|
||||
const int effProcessEvents = 25;
|
||||
const int effGetEffectName = 45;
|
||||
const int effGetVendorString = 47;
|
||||
|
||||
@@ -56,7 +56,7 @@ IF("${PLUGIN_LIST}" STREQUAL "")
|
||||
LadspaEffect
|
||||
lb302
|
||||
MidiImport
|
||||
# MidiExport - temporarily disabled, MIDI export is broken
|
||||
MidiExport
|
||||
MultitapEcho
|
||||
monstro
|
||||
nes
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
* MidiExport.cpp - support for importing MIDI files
|
||||
* MidiExport.cpp - support for Exporting MIDI files
|
||||
*
|
||||
* Author: Mohamed Abdel Maksoud <mohamed at amaksoud.com>
|
||||
* Copyright (c) 2015 Mohamed Abdel Maksoud <mohamed at amaksoud.com>
|
||||
* Copyright (c) 2017 Hyunjin Song <tteu.ingog/at/gmail.com>
|
||||
*
|
||||
* This file is part of LMMS - https://lmms.io
|
||||
*
|
||||
@@ -30,8 +31,10 @@
|
||||
#include <QProgressDialog>
|
||||
|
||||
#include "MidiExport.h"
|
||||
#include "Engine.h"
|
||||
|
||||
#include "lmms_math.h"
|
||||
#include "TrackContainer.h"
|
||||
#include "BBTrack.h"
|
||||
#include "InstrumentTrack.h"
|
||||
|
||||
|
||||
@@ -44,7 +47,8 @@ Plugin::Descriptor PLUGIN_EXPORT midiexport_plugin_descriptor =
|
||||
"MIDI Export",
|
||||
QT_TRANSLATE_NOOP( "pluginBrowser",
|
||||
"Filter for exporting MIDI-files from LMMS" ),
|
||||
"Mohamed Abdel Maksoud <mohamed at amaksoud.com>",
|
||||
"Mohamed Abdel Maksoud <mohamed at amaksoud.com> and "
|
||||
"Hyunjin Song <tteu.ingog/at/gmail.com>",
|
||||
0x0100,
|
||||
Plugin::ExportFilter,
|
||||
NULL,
|
||||
@@ -68,99 +72,269 @@ MidiExport::~MidiExport()
|
||||
|
||||
|
||||
|
||||
bool MidiExport::tryExport( const TrackContainer::TrackList &tracks, int tempo, const QString &filename )
|
||||
bool MidiExport::tryExport(const TrackContainer::TrackList &tracks,
|
||||
const TrackContainer::TrackList &tracks_BB,
|
||||
int tempo, int masterPitch, const QString &filename)
|
||||
{
|
||||
QFile f(filename);
|
||||
f.open(QIODevice::WriteOnly);
|
||||
QDataStream midiout(&f);
|
||||
|
||||
InstrumentTrack* instTrack;
|
||||
BBTrack* bbTrack;
|
||||
QDomElement element;
|
||||
|
||||
|
||||
int nTracks = 0;
|
||||
const int BUFFER_SIZE = 50*1024;
|
||||
uint8_t buffer[BUFFER_SIZE];
|
||||
uint32_t size;
|
||||
|
||||
for( const Track* track : tracks ) if( track->type() == Track::InstrumentTrack ) nTracks++;
|
||||
for (const Track* track : tracks) if (track->type() == Track::InstrumentTrack) nTracks++;
|
||||
for (const Track* track : tracks_BB) if (track->type() == Track::InstrumentTrack) nTracks++;
|
||||
|
||||
// midi header
|
||||
MidiFile::MIDIHeader header(nTracks);
|
||||
size = header.writeToBuffer(buffer);
|
||||
midiout.writeRawData((char *)buffer, size);
|
||||
|
||||
// midi tracks
|
||||
for( Track* track : tracks )
|
||||
{
|
||||
DataFile dataFile( DataFile::SongProject );
|
||||
MidiFile::MIDITrack<BUFFER_SIZE> mtrack;
|
||||
|
||||
if( track->type() != Track::InstrumentTrack ) continue;
|
||||
std::vector<std::vector<std::pair<int,int>>> plists;
|
||||
|
||||
// midi tracks
|
||||
for (Track* track : tracks)
|
||||
{
|
||||
DataFile dataFile(DataFile::SongProject);
|
||||
MTrack mtrack;
|
||||
|
||||
if (track->type() == Track::InstrumentTrack)
|
||||
{
|
||||
|
||||
mtrack.addName(track->name().toStdString(), 0);
|
||||
//mtrack.addProgramChange(0, 0);
|
||||
mtrack.addTempo(tempo, 0);
|
||||
|
||||
instTrack = dynamic_cast<InstrumentTrack *>(track);
|
||||
element = instTrack->saveState(dataFile, dataFile.content());
|
||||
|
||||
int base_pitch = 0;
|
||||
double base_volume = 1.0;
|
||||
int base_time = 0;
|
||||
|
||||
MidiNoteVector pat;
|
||||
|
||||
for (QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling())
|
||||
{
|
||||
|
||||
if (n.nodeName() == "instrumenttrack")
|
||||
{
|
||||
QDomElement it = n.toElement();
|
||||
// transpose +12 semitones, workaround for #1857
|
||||
base_pitch = (69 - it.attribute("basenote", "57").toInt());
|
||||
if (it.attribute("usemasterpitch", "1").toInt())
|
||||
{
|
||||
base_pitch += masterPitch;
|
||||
}
|
||||
base_volume = it.attribute("volume", "100").toDouble()/100.0;
|
||||
}
|
||||
|
||||
if (n.nodeName() == "pattern")
|
||||
{
|
||||
base_time = n.toElement().attribute("pos", "0").toInt();
|
||||
writePattern(pat, n, base_pitch, base_volume, base_time);
|
||||
}
|
||||
|
||||
}
|
||||
ProcessBBNotes(pat, INT_MAX);
|
||||
writePatternToTrack(mtrack, pat);
|
||||
size = mtrack.writeToBuffer(buffer);
|
||||
midiout.writeRawData((char *)buffer, size);
|
||||
}
|
||||
|
||||
if (track->type() == Track::BBTrack)
|
||||
{
|
||||
bbTrack = dynamic_cast<BBTrack *>(track);
|
||||
element = bbTrack->saveState(dataFile, dataFile.content());
|
||||
|
||||
std::vector<std::pair<int,int>> plist;
|
||||
for (QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling())
|
||||
{
|
||||
|
||||
if (n.nodeName() == "bbtco")
|
||||
{
|
||||
QDomElement it = n.toElement();
|
||||
int pos = it.attribute("pos", "0").toInt();
|
||||
int len = it.attribute("len", "0").toInt();
|
||||
plist.push_back(std::pair<int,int>(pos, pos+len));
|
||||
}
|
||||
}
|
||||
std::sort(plist.begin(), plist.end());
|
||||
plists.push_back(plist);
|
||||
|
||||
}
|
||||
} // for each track
|
||||
|
||||
// midi tracks in BB tracks
|
||||
for (Track* track : tracks_BB)
|
||||
{
|
||||
DataFile dataFile(DataFile::SongProject);
|
||||
MTrack mtrack;
|
||||
|
||||
auto itr = plists.begin();
|
||||
std::vector<std::pair<int,int>> st;
|
||||
|
||||
if (track->type() != Track::InstrumentTrack) continue;
|
||||
|
||||
//qDebug() << "exporting " << track->name();
|
||||
|
||||
|
||||
mtrack.addName(track->name().toStdString(), 0);
|
||||
//mtrack.addProgramChange(0, 0);
|
||||
mtrack.addTempo(tempo, 0);
|
||||
|
||||
instTrack = dynamic_cast<InstrumentTrack *>( track );
|
||||
element = instTrack->saveState( dataFile, dataFile.content() );
|
||||
|
||||
// instrumentTrack
|
||||
// - instrumentTrack
|
||||
// - pattern
|
||||
int base_pitch = 0;
|
||||
|
||||
instTrack = dynamic_cast<InstrumentTrack *>(track);
|
||||
element = instTrack->saveState(dataFile, dataFile.content());
|
||||
|
||||
int base_pitch = 0;
|
||||
double base_volume = 1.0;
|
||||
int base_time = 0;
|
||||
|
||||
|
||||
for(QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling())
|
||||
|
||||
for (QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling())
|
||||
{
|
||||
//QDomText txt = n.toText();
|
||||
//qDebug() << ">> child node " << n.nodeName();
|
||||
|
||||
if (n.nodeName() == "instrumenttrack")
|
||||
{
|
||||
// TODO interpret pan="0" fxch="0" usemasterpitch="1" pitchrange="1" pitch="0" basenote="57"
|
||||
QDomElement it = n.toElement();
|
||||
base_pitch = it.attribute("pitch", "0").toInt();
|
||||
base_volume = it.attribute("volume", "100").toDouble()/100.0;
|
||||
// transpose +12 semitones, workaround for #1857
|
||||
base_pitch = (69 - it.attribute("basenote", "57").toInt());
|
||||
if (it.attribute("usemasterpitch", "1").toInt())
|
||||
{
|
||||
base_pitch += masterPitch;
|
||||
}
|
||||
base_volume = it.attribute("volume", "100").toDouble() / 100.0;
|
||||
}
|
||||
|
||||
|
||||
if (n.nodeName() == "pattern")
|
||||
{
|
||||
base_time = n.toElement().attribute("pos", "0").toInt();
|
||||
// TODO interpret steps="12" muted="0" type="1" name="Piano1" len="2592"
|
||||
for(QDomNode nn = n.firstChild(); !nn.isNull(); nn = nn.nextSibling())
|
||||
std::vector<std::pair<int,int>> &plist = *itr;
|
||||
|
||||
MidiNoteVector nv, pat;
|
||||
writePattern(pat, n, base_pitch, base_volume, 0);
|
||||
|
||||
// workaround for nested BBTCOs
|
||||
int pos = 0;
|
||||
int len = n.toElement().attribute("steps", "1").toInt() * 12;
|
||||
for (auto it = plist.begin(); it != plist.end(); ++it)
|
||||
{
|
||||
QDomElement note = nn.toElement();
|
||||
if (note.attribute("len", "0") == "0" || note.attribute("vol", "0") == "0") continue;
|
||||
#if 0
|
||||
qDebug() << ">>>> key " << note.attribute( "key", "0" )
|
||||
<< " " << note.attribute("len", "0") << " @"
|
||||
<< note.attribute("pos", "0");
|
||||
#endif
|
||||
mtrack.addNote(
|
||||
note.attribute("key", "0").toInt()+base_pitch
|
||||
, 100 * base_volume * (note.attribute("vol", "100").toDouble()/100)
|
||||
, (base_time+note.attribute("pos", "0").toDouble())/48
|
||||
, (note.attribute("len", "0")).toDouble()/48);
|
||||
while (!st.empty() && st.back().second <= it->first)
|
||||
{
|
||||
writeBBPattern(pat, nv, len, st.back().first, pos, st.back().second);
|
||||
pos = st.back().second;
|
||||
st.pop_back();
|
||||
}
|
||||
|
||||
if (!st.empty() && st.back().second <= it->second)
|
||||
{
|
||||
writeBBPattern(pat, nv, len, st.back().first, pos, it->first);
|
||||
pos = it->first;
|
||||
while (!st.empty() && st.back().second <= it->second)
|
||||
{
|
||||
st.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
st.push_back(*it);
|
||||
pos = it->first;
|
||||
}
|
||||
|
||||
while (!st.empty())
|
||||
{
|
||||
writeBBPattern(pat, nv, len, st.back().first, pos, st.back().second);
|
||||
pos = st.back().second;
|
||||
st.pop_back();
|
||||
}
|
||||
|
||||
ProcessBBNotes(nv, pos);
|
||||
writePatternToTrack(mtrack, nv);
|
||||
++itr;
|
||||
}
|
||||
|
||||
}
|
||||
size = mtrack.writeToBuffer(buffer);
|
||||
midiout.writeRawData((char *)buffer, size);
|
||||
} // for each track
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MidiExport::writePattern(MidiNoteVector &pat, QDomNode n,
|
||||
int base_pitch, double base_volume, int base_time)
|
||||
{
|
||||
// TODO interpret steps="12" muted="0" type="1" name="Piano1" len="2592"
|
||||
for (QDomNode nn = n.firstChild(); !nn.isNull(); nn = nn.nextSibling())
|
||||
{
|
||||
QDomElement note = nn.toElement();
|
||||
if (note.attribute("len", "0") == "0") continue;
|
||||
// TODO interpret pan="0" fxch="0" pitchrange="1"
|
||||
MidiNote mnote;
|
||||
mnote.pitch = qMax(0, qMin(127, note.attribute("key", "0").toInt() + base_pitch));
|
||||
mnote.volume = qMin(qRound(base_volume * note.attribute("vol", "100").toDouble()), 127);
|
||||
mnote.time = base_time + note.attribute("pos", "0").toInt();
|
||||
mnote.duration = note.attribute("len", "0").toInt();
|
||||
pat.push_back(mnote);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MidiExport::writePatternToTrack(MTrack &mtrack, MidiNoteVector &nv)
|
||||
{
|
||||
for (auto it = nv.begin(); it != nv.end(); ++it)
|
||||
{
|
||||
mtrack.addNote(it->pitch, it->volume, it->time / 48.0, it->duration / 48.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MidiExport::writeBBPattern(MidiNoteVector &src, MidiNoteVector &dst,
|
||||
int len, int base, int start, int end)
|
||||
{
|
||||
if (start >= end) { return; }
|
||||
start -= base;
|
||||
end -= base;
|
||||
std::sort(src.begin(), src.end());
|
||||
for (auto it = src.begin(); it != src.end(); ++it)
|
||||
{
|
||||
for (int time = it->time + ceil((start - it->time) / len)
|
||||
* len; time < end; time += len)
|
||||
{
|
||||
MidiNote note;
|
||||
note.duration = it->duration;
|
||||
note.pitch = it->pitch;
|
||||
note.time = base + time;
|
||||
note.volume = it->volume;
|
||||
dst.push_back(note);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MidiExport::ProcessBBNotes(MidiNoteVector &nv, int cutPos)
|
||||
{
|
||||
std::sort(nv.begin(), nv.end());
|
||||
int cur = INT_MAX, next = INT_MAX;
|
||||
for (auto it = nv.rbegin(); it != nv.rend(); ++it)
|
||||
{
|
||||
if (it->time < cur)
|
||||
{
|
||||
next = cur;
|
||||
cur = it->time;
|
||||
}
|
||||
if (it->duration < 0)
|
||||
{
|
||||
it->duration = qMin(qMin(-it->duration, next - cur), cutPos - it->time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MidiExport::error()
|
||||
{
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
* MidiExport.h - support for Exporting MIDI-files
|
||||
*
|
||||
* Author: Mohamed Abdel Maksoud <mohamed at amaksoud.com>
|
||||
* Copyright (c) 2015 Mohamed Abdel Maksoud <mohamed at amaksoud.com>
|
||||
* Copyright (c) 2017 Hyunjin Song <tteu.ingog/at/gmail.com>
|
||||
*
|
||||
* This file is part of LMMS - https://lmms.io
|
||||
*
|
||||
@@ -31,25 +32,52 @@
|
||||
#include "MidiFile.hpp"
|
||||
|
||||
|
||||
const int BUFFER_SIZE = 50*1024;
|
||||
typedef MidiFile::MIDITrack<BUFFER_SIZE> MTrack;
|
||||
|
||||
struct MidiNote
|
||||
{
|
||||
int time;
|
||||
uint8_t pitch;
|
||||
int duration;
|
||||
uint8_t volume;
|
||||
|
||||
inline bool operator<(const MidiNote &b) const
|
||||
{
|
||||
return this->time < b.time;
|
||||
}
|
||||
} ;
|
||||
|
||||
typedef std::vector<MidiNote> MidiNoteVector;
|
||||
typedef std::vector<MidiNote>::iterator MidiNoteIterator;
|
||||
|
||||
|
||||
|
||||
class MidiExport: public ExportFilter
|
||||
{
|
||||
// Q_OBJECT
|
||||
public:
|
||||
MidiExport( );
|
||||
MidiExport();
|
||||
~MidiExport();
|
||||
|
||||
virtual PluginView * instantiateView( QWidget * )
|
||||
virtual PluginView *instantiateView(QWidget *)
|
||||
{
|
||||
return( NULL );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual bool tryExport( const TrackContainer::TrackList &tracks, int tempo, const QString &filename );
|
||||
virtual bool tryExport(const TrackContainer::TrackList &tracks,
|
||||
const TrackContainer::TrackList &tracks_BB,
|
||||
int tempo, int masterPitch, const QString &filename);
|
||||
|
||||
private:
|
||||
|
||||
void writePattern(MidiNoteVector &pat, QDomNode n,
|
||||
int base_pitch, double base_volume, int base_time);
|
||||
void writePatternToTrack(MTrack &mtrack, MidiNoteVector &nv);
|
||||
void writeBBPattern(MidiNoteVector &src, MidiNoteVector &dst,
|
||||
int len, int base, int start, int end);
|
||||
void ProcessBBNotes(MidiNoteVector &nv, int cutPos);
|
||||
|
||||
void error( void );
|
||||
void error();
|
||||
|
||||
|
||||
} ;
|
||||
|
||||
@@ -156,8 +156,10 @@ struct Event
|
||||
writeBigEndian4(int(60000000.0 / tempo), fourbytes);
|
||||
|
||||
//printf("tempo of %x translates to ", tempo);
|
||||
/*
|
||||
for (int i=0; i<3; i++) printf("%02x ", fourbytes[i+1]);
|
||||
printf("\n");
|
||||
*/
|
||||
buffer[size++] = fourbytes[1];
|
||||
buffer[size++] = fourbytes[2];
|
||||
buffer[size++] = fourbytes[3];
|
||||
@@ -186,7 +188,8 @@ struct Event
|
||||
|
||||
// events are sorted by their time
|
||||
inline bool operator < (const Event& b) const {
|
||||
return this->time < b.time;
|
||||
return this->time < b.time ||
|
||||
(this->time == b.time && this->type > b.type);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <QMenu>
|
||||
#include <QDomElement>
|
||||
|
||||
#include "BufferManager.h"
|
||||
#include "ConfigManager.h"
|
||||
#include "Engine.h"
|
||||
#include "gui_templates.h"
|
||||
@@ -282,16 +283,19 @@ void vestigeInstrument::loadFile( const QString & _file )
|
||||
void vestigeInstrument::play( sampleFrame * _buf )
|
||||
{
|
||||
m_pluginMutex.lock();
|
||||
|
||||
const fpp_t frames = Engine::mixer()->framesPerPeriod();
|
||||
|
||||
if( m_plugin == NULL )
|
||||
{
|
||||
BufferManager::clear( _buf, frames );
|
||||
|
||||
m_pluginMutex.unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
m_plugin->process( NULL, _buf );
|
||||
|
||||
const fpp_t frames = Engine::mixer()->framesPerPeriod();
|
||||
|
||||
instrumentTrack()->processAudioBuffer( _buf, frames, NULL );
|
||||
|
||||
m_pluginMutex.unlock();
|
||||
|
||||
@@ -1385,20 +1385,7 @@ void RemoteVstPlugin::loadPresetFile( const std::string & _file )
|
||||
|
||||
void RemoteVstPlugin::loadChunkFromFile( const std::string & _file, int _len )
|
||||
{
|
||||
char * buf = NULL;
|
||||
|
||||
void * chunk = NULL;
|
||||
// various plugins need this in order to not crash when setting
|
||||
// chunk (also we let the plugin allocate "safe" memory this way)
|
||||
const int actualLen = pluginDispatch( 23, 0, 0, &chunk );
|
||||
|
||||
// allocated buffer big enough?
|
||||
if( _len > actualLen )
|
||||
{
|
||||
// no, then manually allocate a buffer
|
||||
buf = new char[_len];
|
||||
chunk = buf;
|
||||
}
|
||||
char * chunk = new char[_len];
|
||||
|
||||
const int fd = open( _file.c_str(), O_RDONLY | O_BINARY );
|
||||
if ( ::read( fd, chunk, _len ) != _len )
|
||||
@@ -1406,9 +1393,10 @@ void RemoteVstPlugin::loadChunkFromFile( const std::string & _file, int _len )
|
||||
fprintf( stderr, "Error loading chunk from file.\n" );
|
||||
}
|
||||
close( fd );
|
||||
pluginDispatch( 24, 0, _len, chunk );
|
||||
|
||||
delete[] buf;
|
||||
pluginDispatch( effSetChunk, 0, _len, chunk );
|
||||
|
||||
delete[] chunk;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* BufferManager.cpp - A buffer caching/memory management system
|
||||
*
|
||||
* Copyright (c) 2017 Lukas W <lukaswhl/at/gmail.com>
|
||||
* Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>
|
||||
* Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
@@ -25,56 +26,28 @@
|
||||
|
||||
#include "BufferManager.h"
|
||||
|
||||
#include "Engine.h"
|
||||
#include "Mixer.h"
|
||||
#include "MemoryManager.h"
|
||||
|
||||
sampleFrame ** BufferManager::s_available;
|
||||
AtomicInt BufferManager::s_availableIndex = 0;
|
||||
sampleFrame ** BufferManager::s_released;
|
||||
AtomicInt BufferManager::s_releasedIndex = 0;
|
||||
//QReadWriteLock BufferManager::s_mutex;
|
||||
int BufferManager::s_size;
|
||||
|
||||
static fpp_t framesPerPeriod;
|
||||
|
||||
void BufferManager::init( fpp_t framesPerPeriod )
|
||||
{
|
||||
s_available = MM_ALLOC( sampleFrame*, BM_INITIAL_BUFFERS );
|
||||
s_released = MM_ALLOC( sampleFrame*, BM_INITIAL_BUFFERS );
|
||||
|
||||
int c = framesPerPeriod * BM_INITIAL_BUFFERS;
|
||||
sampleFrame * b = MM_ALLOC( sampleFrame, c );
|
||||
|
||||
for( int i = 0; i < BM_INITIAL_BUFFERS; ++i )
|
||||
{
|
||||
s_available[ i ] = b;
|
||||
b += framesPerPeriod;
|
||||
}
|
||||
s_availableIndex = BM_INITIAL_BUFFERS - 1;
|
||||
s_size = BM_INITIAL_BUFFERS;
|
||||
::framesPerPeriod = framesPerPeriod;
|
||||
}
|
||||
|
||||
|
||||
sampleFrame * BufferManager::acquire()
|
||||
{
|
||||
if( s_availableIndex < 0 )
|
||||
{
|
||||
qFatal( "BufferManager: out of buffers" );
|
||||
}
|
||||
|
||||
int i = s_availableIndex.fetchAndAddOrdered( -1 );
|
||||
sampleFrame * b = s_available[ i ];
|
||||
|
||||
//qDebug( "acquired buffer: %p - index %d", b, i );
|
||||
return b;
|
||||
return MM_ALLOC( sampleFrame, ::framesPerPeriod );
|
||||
}
|
||||
|
||||
|
||||
void BufferManager::clear( sampleFrame * ab, const f_cnt_t frames,
|
||||
const f_cnt_t offset )
|
||||
void BufferManager::clear( sampleFrame *ab, const f_cnt_t frames, const f_cnt_t offset )
|
||||
{
|
||||
memset( ab + offset, 0, sizeof( *ab ) * frames );
|
||||
}
|
||||
|
||||
|
||||
#ifndef LMMS_DISABLE_SURROUND
|
||||
void BufferManager::clear( surroundSampleFrame * ab, const f_cnt_t frames,
|
||||
const f_cnt_t offset )
|
||||
@@ -86,43 +59,6 @@ void BufferManager::clear( surroundSampleFrame * ab, const f_cnt_t frames,
|
||||
|
||||
void BufferManager::release( sampleFrame * buf )
|
||||
{
|
||||
if (buf == nullptr) return;
|
||||
int i = s_releasedIndex.fetchAndAddOrdered( 1 );
|
||||
s_released[ i ] = buf;
|
||||
//qDebug( "released buffer: %p - index %d", buf, i );
|
||||
MM_FREE( buf );
|
||||
}
|
||||
|
||||
|
||||
void BufferManager::refresh() // non-threadsafe, hence it's called periodically from mixer at a time when no other threads can interfere
|
||||
{
|
||||
if( s_releasedIndex == 0 ) return;
|
||||
//qDebug( "refresh: %d buffers", int( s_releasedIndex ) );
|
||||
|
||||
int j = s_availableIndex;
|
||||
for( int i = 0; i < s_releasedIndex; ++i )
|
||||
{
|
||||
++j;
|
||||
s_available[ j ] = s_released[ i ];
|
||||
}
|
||||
s_availableIndex = j;
|
||||
s_releasedIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
/* // non-extensible for now
|
||||
void BufferManager::extend( int c )
|
||||
{
|
||||
s_size += c;
|
||||
sampleFrame ** tmp = MM_ALLOC( sampleFrame*, s_size );
|
||||
MM_FREE( s_available );
|
||||
s_available = tmp;
|
||||
|
||||
int cc = c * Engine::mixer()->framesPerPeriod();
|
||||
sampleFrame * b = MM_ALLOC( sampleFrame, cc );
|
||||
|
||||
for( int i = 0; i < c; ++i )
|
||||
{
|
||||
s_available[ s_availableIndex.fetchAndAddOrdered( 1 ) + 1 ] = b;
|
||||
b += Engine::mixer()->framesPerPeriod();
|
||||
}
|
||||
}*/
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
* Allocate a number of bytes and return them.
|
||||
* @param byteNum is the number of bytes
|
||||
*/
|
||||
void* MemoryHelper::alignedMalloc( int byteNum )
|
||||
void* MemoryHelper::alignedMalloc( size_t byteNum )
|
||||
{
|
||||
char *ptr, *ptr2, *aligned_ptr;
|
||||
int align_mask = ALIGN_SIZE - 1;
|
||||
|
||||
@@ -482,9 +482,6 @@ const surroundSampleFrame * Mixer::renderNextBuffer()
|
||||
Controller::triggerFrameCounter();
|
||||
AutomatableModel::incrementPeriodCounter();
|
||||
|
||||
// refresh buffer pool
|
||||
BufferManager::refresh();
|
||||
|
||||
s_renderingThread = false;
|
||||
|
||||
m_profiler.finishPeriod( processingSampleRate(), m_framesPerPeriod );
|
||||
|
||||
@@ -252,17 +252,8 @@ void NotePlayHandle::play( sampleFrame * _working_buffer )
|
||||
if( m_released && (!instrumentTrack()->isSustainPedalPressed() ||
|
||||
m_releaseStarted) )
|
||||
{
|
||||
if (m_releaseStarted == false)
|
||||
{
|
||||
m_releaseStarted = true;
|
||||
|
||||
if( m_origin == OriginMidiInput )
|
||||
{
|
||||
setLength( MidiTime( static_cast<f_cnt_t>( totalFramesPlayed() / Engine::framesPerTick() ) ) );
|
||||
m_instrumentTrack->midiNoteOff( *this );
|
||||
}
|
||||
|
||||
m_releaseStarted = true;
|
||||
}
|
||||
f_cnt_t todo = framesThisPeriod;
|
||||
|
||||
// if this note is base-note for arpeggio, always set
|
||||
@@ -389,6 +380,16 @@ void NotePlayHandle::noteOff( const f_cnt_t _s )
|
||||
MidiTime::fromFrames( _s, Engine::framesPerTick() ),
|
||||
_s );
|
||||
}
|
||||
|
||||
// inform attached components about MIDI finished (used for recording in Piano Roll)
|
||||
if (!instrumentTrack()->isSustainPedalPressed())
|
||||
{
|
||||
if( m_origin == OriginMidiInput )
|
||||
{
|
||||
setLength( MidiTime( static_cast<f_cnt_t>( totalFramesPlayed() / Engine::framesPerTick() ) ) );
|
||||
m_instrumentTrack->midiNoteOff( *this );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,16 +24,21 @@
|
||||
|
||||
#include "PlayHandle.h"
|
||||
#include "BufferManager.h"
|
||||
#include "Engine.h"
|
||||
#include "Mixer.h"
|
||||
|
||||
#include <QtCore/QThread>
|
||||
#include <QDebug>
|
||||
|
||||
#include <iterator>
|
||||
|
||||
PlayHandle::PlayHandle( const Type type, f_cnt_t offset ) :
|
||||
m_type( type ),
|
||||
m_offset( offset ),
|
||||
m_affinity( QThread::currentThread() ),
|
||||
m_playHandleBuffer( NULL ),
|
||||
m_usesBuffer( true )
|
||||
PlayHandle::PlayHandle(const Type type, f_cnt_t offset) :
|
||||
m_type(type),
|
||||
m_offset(offset),
|
||||
m_affinity(QThread::currentThread()),
|
||||
m_playHandleBuffer(BufferManager::acquire()),
|
||||
m_bufferReleased(true),
|
||||
m_usesBuffer(true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -48,8 +53,8 @@ void PlayHandle::doProcessing()
|
||||
{
|
||||
if( m_usesBuffer )
|
||||
{
|
||||
if( ! m_playHandleBuffer ) m_playHandleBuffer = BufferManager::acquire();
|
||||
play( m_playHandleBuffer );
|
||||
m_bufferReleased = false;
|
||||
play( buffer() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -60,6 +65,10 @@ void PlayHandle::doProcessing()
|
||||
|
||||
void PlayHandle::releaseBuffer()
|
||||
{
|
||||
BufferManager::release( m_playHandleBuffer );
|
||||
m_playHandleBuffer = NULL;
|
||||
m_bufferReleased = true;
|
||||
}
|
||||
|
||||
sampleFrame* PlayHandle::buffer()
|
||||
{
|
||||
return m_bufferReleased ? nullptr : reinterpret_cast<sampleFrame*>(m_playHandleBuffer);
|
||||
};
|
||||
|
||||
@@ -1435,14 +1435,15 @@ void Song::exportProjectMidi()
|
||||
|
||||
// instantiate midi export plugin
|
||||
TrackContainer::TrackList tracks;
|
||||
tracks += Engine::getSong()->tracks();
|
||||
tracks += Engine::getBBTrackContainer()->tracks();
|
||||
TrackContainer::TrackList tracks_BB;
|
||||
tracks = Engine::getSong()->tracks();
|
||||
tracks_BB = Engine::getBBTrackContainer()->tracks();
|
||||
ExportFilter *exf = dynamic_cast<ExportFilter *> (Plugin::instantiate("midiexport", NULL, NULL));
|
||||
if (exf==NULL) {
|
||||
qDebug() << "failed to load midi export filter!";
|
||||
return;
|
||||
}
|
||||
exf->tryExport(tracks, Engine::getSong()->getTempo(), export_filename);
|
||||
exf->tryExport(tracks, tracks_BB, getTempo(), m_masterPitchModel.value(), export_filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ AudioPort::AudioPort( const QString & _name, bool _has_effect_chain,
|
||||
FloatModel * volumeModel, FloatModel * panningModel,
|
||||
BoolModel * mutedModel ) :
|
||||
m_bufferUsage( false ),
|
||||
m_portBuffer( NULL ),
|
||||
m_portBuffer( BufferManager::acquire() ),
|
||||
m_extOutputEnabled( false ),
|
||||
m_nextFxChannel( 0 ),
|
||||
m_name( "unnamed port" ),
|
||||
@@ -57,6 +57,7 @@ AudioPort::~AudioPort()
|
||||
setExtOutputEnabled( false );
|
||||
Engine::mixer()->removeAudioPort( this );
|
||||
delete m_effects;
|
||||
BufferManager::release( m_portBuffer );
|
||||
}
|
||||
|
||||
|
||||
@@ -110,8 +111,7 @@ void AudioPort::doProcessing()
|
||||
|
||||
const fpp_t fpp = Engine::mixer()->framesPerPeriod();
|
||||
|
||||
// get a buffer for processing and clear it
|
||||
m_portBuffer = BufferManager::acquire();
|
||||
// clear the buffer
|
||||
BufferManager::clear( m_portBuffer, fpp );
|
||||
|
||||
//qDebug( "Playhandles: %d", m_playHandles.size() );
|
||||
@@ -225,8 +225,6 @@ void AudioPort::doProcessing()
|
||||
// TODO: improve the flow here - convert to pull model
|
||||
m_bufferUsage = false;
|
||||
}
|
||||
|
||||
BufferManager::release( m_portBuffer ); // release buffer, we don't need it anymore
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QtGlobal>
|
||||
#include <QMessageBox>
|
||||
#include <QSplashScreen>
|
||||
|
||||
@@ -54,6 +55,11 @@ GuiApplication* GuiApplication::instance()
|
||||
|
||||
GuiApplication::GuiApplication()
|
||||
{
|
||||
// enable HiDPI scaling before showing anything (Qt 5.6+ only)
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
|
||||
#endif
|
||||
|
||||
// prompt the user to create the LMMS working directory (e.g. ~/lmms) if it doesn't exist
|
||||
if ( !ConfigManager::inst()->hasWorkingDir() &&
|
||||
QMessageBox::question( NULL,
|
||||
|
||||
@@ -62,3 +62,27 @@ bool MainApplication::event(QEvent* event)
|
||||
return QApplication::event(event);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LMMS_BUILD_WIN32
|
||||
bool MainApplication::winEventFilter(MSG* msg, long* result)
|
||||
{
|
||||
switch(msg->message)
|
||||
{
|
||||
case WM_STYLECHANGING:
|
||||
if(msg->wParam == GWL_EXSTYLE)
|
||||
{
|
||||
// Prevent plugins making the main window transparent
|
||||
STYLESTRUCT * style = reinterpret_cast<STYLESTRUCT *>(msg->lParam);
|
||||
if(!(style->styleOld & WS_EX_LAYERED))
|
||||
{
|
||||
style->styleNew &= ~WS_EX_LAYERED;
|
||||
}
|
||||
*result = 0;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#include "PluginView.h"
|
||||
#include "ProjectJournal.h"
|
||||
#include "ProjectNotes.h"
|
||||
#include "RemotePlugin.h"
|
||||
#include "SetupDialog.h"
|
||||
#include "SideBar.h"
|
||||
#include "SongEditor.h"
|
||||
@@ -300,12 +301,11 @@ void MainWindow::finalize()
|
||||
SLOT( exportProjectTracks() ),
|
||||
Qt::CTRL + Qt::SHIFT + Qt::Key_E );
|
||||
|
||||
// temporarily disabled broken MIDI export
|
||||
/*project_menu->addAction( embed::getIconPixmap( "midi_file" ),
|
||||
project_menu->addAction( embed::getIconPixmap( "midi_file" ),
|
||||
tr( "Export &MIDI..." ),
|
||||
Engine::getSong(),
|
||||
SLOT( exportProjectMidi() ),
|
||||
Qt::CTRL + Qt::Key_M );*/
|
||||
Qt::CTRL + Qt::Key_M );
|
||||
|
||||
// Prevent dangling separator at end of menu per https://bugreports.qt.io/browse/QTBUG-40071
|
||||
#if !(defined(LMMS_BUILD_APPLE) && (QT_VERSION >= 0x050000) && (QT_VERSION < 0x050600))
|
||||
@@ -1536,14 +1536,14 @@ void MainWindow::browseHelp()
|
||||
void MainWindow::autoSave()
|
||||
{
|
||||
if( !Engine::getSong()->isExporting() &&
|
||||
!Engine::getSong()->isLoadingProject() &&
|
||||
!RemotePluginBase::isMainThreadWaiting() &&
|
||||
!QApplication::mouseButtons() &&
|
||||
( ConfigManager::inst()->value( "ui",
|
||||
"enablerunningautosave" ).toInt() ||
|
||||
! Engine::getSong()->isPlaying() ) )
|
||||
( ConfigManager::inst()->value( "ui",
|
||||
"enablerunningautosave" ).toInt() ||
|
||||
! Engine::getSong()->isPlaying() ) )
|
||||
{
|
||||
AutoSaveThread * ast = new AutoSaveThread();
|
||||
connect( ast, SIGNAL( finished() ), ast, SLOT( deleteLater() ) );
|
||||
ast->start();
|
||||
Engine::getSong()->saveProjectFile(ConfigManager::inst()->recoveryFile());
|
||||
autoSaveTimerReset(); // Reset timer
|
||||
}
|
||||
else
|
||||
@@ -1555,11 +1555,3 @@ void MainWindow::autoSave()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AutoSaveThread::run()
|
||||
{
|
||||
Engine::getSong()->saveProjectFile(ConfigManager::inst()->recoveryFile());
|
||||
}
|
||||
|
||||
@@ -157,7 +157,8 @@ InstrumentTrack::~InstrumentTrack()
|
||||
void InstrumentTrack::processAudioBuffer( sampleFrame* buf, const fpp_t frames, NotePlayHandle* n )
|
||||
{
|
||||
// we must not play the sound if this InstrumentTrack is muted...
|
||||
if( isMuted() || ( n && n->isBbTrackMuted() ) || ! m_instrument )
|
||||
if( isMuted() || ( Engine::getSong()->playMode() != Song::Mode_PlayPattern &&
|
||||
n && n->isBbTrackMuted() ) || ! m_instrument )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -237,6 +238,11 @@ MidiEvent InstrumentTrack::applyMasterKey( const MidiEvent& event )
|
||||
|
||||
void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& time, f_cnt_t offset )
|
||||
{
|
||||
if( Engine::getSong()->isExporting() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool eventHandled = false;
|
||||
|
||||
switch( event.type() )
|
||||
@@ -273,6 +279,12 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& ti
|
||||
// be deleted later automatically)
|
||||
Engine::mixer()->requestChangeInModel();
|
||||
m_notes[event.key()]->noteOff( offset );
|
||||
if (isSustainPedalPressed() &&
|
||||
m_notes[event.key()]->origin() ==
|
||||
m_notes[event.key()]->OriginMidiInput)
|
||||
{
|
||||
m_sustainedNotes << m_notes[event.key()];
|
||||
}
|
||||
m_notes[event.key()] = NULL;
|
||||
Engine::mixer()->doneChangeInModel();
|
||||
}
|
||||
@@ -302,8 +314,24 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& ti
|
||||
{
|
||||
m_sustainPedalPressed = true;
|
||||
}
|
||||
else
|
||||
else if (isSustainPedalPressed())
|
||||
{
|
||||
for (NotePlayHandle* nph : m_sustainedNotes)
|
||||
{
|
||||
if (nph && nph->isReleased())
|
||||
{
|
||||
if( nph->origin() ==
|
||||
nph->OriginMidiInput)
|
||||
{
|
||||
nph->setLength(
|
||||
MidiTime( static_cast<f_cnt_t>(
|
||||
nph->totalFramesPlayed() /
|
||||
Engine::framesPerTick() ) ) );
|
||||
midiNoteOff( *nph );
|
||||
}
|
||||
}
|
||||
}
|
||||
m_sustainedNotes.clear();
|
||||
m_sustainPedalPressed = false;
|
||||
}
|
||||
}
|
||||
@@ -586,7 +614,10 @@ bool InstrumentTrack::play( const MidiTime & _start, const fpp_t _frames,
|
||||
{
|
||||
TrackContentObject * tco = getTCO( _tco_num );
|
||||
tcos.push_back( tco );
|
||||
bb_track = BBTrack::findBBTrack( _tco_num );
|
||||
if (trackContainer() == (TrackContainer*)Engine::getBBTrackContainer())
|
||||
{
|
||||
bb_track = BBTrack::findBBTrack( _tco_num );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -594,7 +594,10 @@ bool SampleTrack::play( const MidiTime & _start, const fpp_t _frames,
|
||||
return false;
|
||||
}
|
||||
tcos.push_back( getTCO( _tco_num ) );
|
||||
bb_track = BBTrack::findBBTrack( _tco_num );
|
||||
if (trackContainer() == (TrackContainer*)Engine::getBBTrackContainer())
|
||||
{
|
||||
bb_track = BBTrack::findBBTrack( _tco_num );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user