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

Linux build #10

Merged
merged 6 commits into from
Jun 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions qt/build-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/sh

BIN=kerberos.bin
RELDIR=kerberos

if [ -d "$RELDIR" ]
then
read -p "[*] Release directory exists. Clean release [y/n]? " yn
while true; do
case $yn in
[Yy]* ) rm -rf $RELDIR; break;;
[Nn]* ) echo "[*] Abort"; exit;;
* ) echo "Please answer yes or no [y/n].";;
esac
done
fi

echo "[*] Building application"
qmake
make

if [ $? -eq 0 ]
then
echo "[*] Build successful"
echo "[*] Creating release subdirectories"
mkdir -p $RELDIR
mkdir -p $RELDIR/bin
mkdir -p $RELDIR/lib

echo "[*] Copying files"
echo "$BIN --> $RELDIR/bin"
cp kerberos.bin $RELDIR/bin

LIBS=`ldd kerberos.bin | grep -e Qt -e icu -e gcc -e stdc++ -e pthread -e png | awk '{print $3}'`
for LIB in $LIBS; do
echo "$LIB --> $RELDIR/lib"
cp $LIB $RELDIR/lib
done

SCRIPT=$RELDIR/kerberos.sh
echo "[*] Creating startup script $SCRIPT"
touch $SCRIPT
echo '#/bin/sh' >> $SCRIPT
echo 'export LD_LIBRARY_PATH="'`pwd`/$RELDIR/lib'${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"' >> $SCRIPT
echo "bin/$BIN" '$@' >> $SCRIPT
chmod u+x $SCRIPT
else
echo "[*] Could not build application"
fi

7 changes: 7 additions & 0 deletions qt/kerberos.pro
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,12 @@ win32:DEFINES += __WINDOWS_MM__
win32:LIBS += -lwinmm
win32:LIBS += -lws2_32

unix:DEFINES += __LINUX_ALSASEQ__
unix:LIBS += -lasound
unix:TARGET = kerberos.bin

# unix:DEFINES += __LINUX_JACK__
# unix:LIBS += -ljack

RESOURCES = application.qrc
RC_ICONS = kerberos.ico
43 changes: 36 additions & 7 deletions qt/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,49 @@ class Helper: public QThread {
{
QThread::msleep(ms);
}

static void usleep(int us)
{
QThread::usleep(us);
}
};

void myMsleep(int milliseconds)
{
Helper::msleep(milliseconds);
}

const char* g_midiInInterfaceName = "midiInInterfaceName";
const char* g_midiOutInterfaceName = "midiOutInterfaceName";
void myUsleep(int microseconds)
{
Helper::usleep(microseconds);
}

const char* g_midiInInterfaceName = "Kerberos MIDI In";
const char* g_midiOutInterfaceName = "Kerberos MIDI Out";

const char g_kerberosPrgSlotId[16] = KERBEROS_PRG_SLOT_ID;
const char g_kerberosMenuId[16] = { 75, 69, 82, 66, 69, 82, 79, 83, 32, 77, 69, 78, 85, 32, 73, 68 };

#if defined(__MACOSX_CORE__)
RtMidiOutCoreMidi g_midiOut;
RtMidiInCoreMidi g_midiIn;
RtMidiOutCoreMidi g_midiOut( g_midiOutInterfaceName );;
RtMidiInCoreMidi g_midiIn( g_midiInInterfaceName );;
#elif defined(__LINUX_ALSASEQ__)
RtMidiOutAlsa g_midiOut( g_midiOutInterfaceName );
RtMidiInAlsa g_midiIn( g_midiInInterfaceName );

// delay in microseconds after each send command.
// This is used to fix ALSA buffer overflow when
// large amounts of data are transferred.
static int g_senddelay = 400;

#elif defined(__LINUX_JACK__)

// Not tested yet
RtMidiOutJack g_midiOut( g_midiOutInterfaceName );;
RtMidiInJack g_midiIn( g_midiInInterfaceName );;
#else
RtMidiOutWinMM g_midiOut;
RtMidiInWinMM g_midiIn;
RtMidiOutWinMM g_midiOut( g_midiOutInterfaceName );;
RtMidiInWinMM g_midiIn( g_midiInInterfaceName );;
#endif

int g_lastByte;
Expand Down Expand Up @@ -208,7 +232,7 @@ static void sendNoteOnOff(uint8_t msg, uint8_t note, uint8_t velocity)
fflush(stdout);
*/
} catch (RtError& err) {
//qWarning() << QString::fromStdString(err.getMessage());
std::cout << err.getMessage();
}
}

Expand Down Expand Up @@ -302,6 +326,11 @@ static void midiSendCommand(uint8_t tag, ByteArray data)
// send data
for (size_t i = 0; i < data.size(); i++) {
midiSendByte(data[i]);
#if defined(__LINUX_ALSASEQ__)

// send delay to fix ALSA message dropping
myUsleep(g_senddelay);
#endif
crc8Update(data[i]);
}

Expand Down