Skip to content

Commit

Permalink
XMIDIX
Browse files Browse the repository at this point in the history
  • Loading branch information
bsdf committed May 31, 2022
0 parents commit 51f705d
Show file tree
Hide file tree
Showing 48 changed files with 13,718 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cmake-build-*
compile_commands.json
build
.idea
70 changes: 70 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.17)

PROJECT(XMIDIX VERSION 1.0 LANGUAGES CXX)

SET(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(CMAKE_EXPORT_COMPILE_COMMANDS ON)

SET(CMAKE_AUTOUIC ON)
SET(CMAKE_AUTOMOC ON)
SET(CMAKE_AUTORCC ON)

SET(CMAKE_CXX_STANDARD 20)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")

FIND_PACKAGE(Qt5 COMPONENTS Widgets REQUIRED)
FIND_PACKAGE(Threads REQUIRED)
FIND_PACKAGE(spdlog REQUIRED)
FIND_PACKAGE(fmt REQUIRED)

INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(ALSA REQUIRED alsa)

INCLUDE(cmake/Midifile.cmake)

SET(PROJECT_SOURCES
xmidix.cc
xmidix_player.cc
xmidix_player.h
xmidix_file.cc
xmidix_file.h
xmidix_seq.cc
xmidix_seq.h
xmidix_config.cc
xmidix_config.h
xmidix_playlist.cc
xmidix_playlist.h
resources/resources.qrc
xmidix_vu.cc
xmidix_vu.h
xmidix_piano.cc
xmidix_piano.h
)

ADD_EXECUTABLE(xmidix ${PROJECT_SOURCES})

TARGET_INCLUDE_DIRECTORIES(xmidix PRIVATE
${midifile_INCLUDE_DIRS}
${ALSA_INCLUDE_DIRS}
)

TARGET_LINK_LIBRARIES(xmidix PRIVATE
Qt5::Widgets
Threads::Threads
spdlog::spdlog
fmt::fmt
midifile
${ALSA_LIBRARIES}
)

INSTALL(TARGETS xmidix DESTINATION bin)
INSTALL(FILES resources/xmidix.desktop DESTINATION share/applications)

SET(CPACK_PACKAGE_CONTACT EMAILBEN145@gmail.com)
SET(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "hardware MIDI player")
SET(CPACK_DEBIAN_PACKAGE_SECTION sound)
SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
INCLUDE(CPack)
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
XMIDIX
=========
XMIDIX is a MIDI hardware device player for the X Window System not written in Rust.
dust off the SC-55, load up some MIDIs and hear the music in stunning fidelity the way the artist intended.

there are plenty of GUIs for playing MIDIs on softsynths but not too many for hardsynths.
XMIDIX was written to fill that gap.

![SCREENSHOT](./resources/shot.png)

## REQUIREMENTS
XMIDIX requires the following libraries:
* Qt5
* spdlog
* fmt
* asound2

## KEYBOARD SHORTCUTS
* `SPACE` - play/pause
* `CTRL + o` - load files
* `CTRL + SPACE` - stop
* `CTRL + p` - configuration
* `CTRL + LEFT` - previous
* `CTRL + RIGHT` - next

## TROUBLESHOOTING
### THERE IS NO SOUND
XMIDIX is a MIDI hardware device player so unless you have MIDI hardware
hooked up to your computer, nothing will happen. if you would like to use this
software with a softsynth, the author recommends [Fluidsynth](https://github.com/FluidSynth/fluidsynth)
with the [Windows](https://musical-artifacts.com/artifacts/713) soundfont.

### IT SOUNDS WEIRD AFTER I SEEK
you have likely skipped over control messages which set up the instruments, tempo, etc.
use sparingly.

### I WOULD LIKE TO RECOMMEND THIS TO MY FRIENDS AND FAMILY BUT I DON’T KNOW HOW TO PRONOUNCE THE NAME
XMIDIX must not be spoken out loud but, should you choose to go against the author's wishes,
"X MIDI 10" or "10 MIDI 10" is acceptable.

### I FOUND A BUG
nice.

### I DON’T HAVE ANYTHING TO LISTEN TO
start [here](https://archive.org/details/FALCOM_MIDI)

### DOES THIS WORK ON WINDOWS
the software was written for Linux but some users on the forum
have had luck with [getting it running on Windows](https://goatse.cx/).

## ACKNOWLEDGEMENTS
XMIDIX uses the [Midifile](https://github.com/craigsapp/midifile) library for SMF parsing.
11 changes: 11 additions & 0 deletions cmake/Midifile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
SET(midifile_INCLUDE_DIRS
${PROJECT_SOURCE_DIR}/midifile/include)

FILE(GLOB midifile_SOURCES
${PROJECT_SOURCE_DIR}/midifile/src/*.cpp)

ADD_LIBRARY(midifile STATIC
${midifile_SOURCES})

TARGET_INCLUDE_DIRECTORIES(midifile PRIVATE
${midifile_INCLUDE_DIRS})
22 changes: 22 additions & 0 deletions cmake/XMIDIXED.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
SET(XMIDIXED_SOURCES
xmidixed.cc
xmidix_file.cc
pw/midifile.c
)

ADD_EXECUTABLE(xmidixed
${XMIDIXED_SOURCES}
)

TARGET_INCLUDE_DIRECTORIES(xmidixed PRIVATE
${ALSA_INCLUDE_DIRS}
${SMF_INCLUDE_DIRS}
)

TARGET_LINK_LIBRARIES(xmidixed PRIVATE
Qt5::Widgets
spdlog::spdlog
fmt::fmt
${ALSA_LIBRARIES}
${SMF_LIBRARIES}
)
23 changes: 23 additions & 0 deletions midifile/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Copyright (c) 1999-2018, Craig Stuart Sapp
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
and the following disclaimer in the documentation and/or other materials
provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

159 changes: 159 additions & 0 deletions midifile/include/Binasc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
//
// Programmer: Craig Stuart Sapp <craig@ccrma.stanford.edu>
// Creation Date: Mon Feb 16 12:26:32 PST 2015 Adapted from binasc program.
// Last Modified: Sat Apr 21 10:52:19 PDT 2018 Removed using namespace std;
// Filename: midifile/include/Binasc.h
// Website: http://midifile.sapp.org
// Syntax: C++11
// vim: ts=3 noexpandtab
//
// description: Interface to convert bytes between binary and ASCII forms.
//

#ifndef _BINASC_H_INCLUDED
#define _BINASC_H_INCLUDED

#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <stdlib.h> /* needed for MinGW */

namespace smf {

typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned long ulong;

class Binasc {

public:
Binasc (void);

~Binasc ();

// functions for setting options:
int setLineLength (int length);
int getLineLength (void);
int setLineBytes (int length);
int getLineBytes (void);
void setComments (int state);
void setCommentsOn (void);
void setCommentsOff (void);
int getComments (void);
void setBytes (int state);
void setBytesOn (void);
void setBytesOff (void);
int getBytes (void);
void setMidi (int state);
void setMidiOn (void);
void setMidiOff (void);
int getMidi (void);

// functions for converting into a binary file:
int writeToBinary (const std::string& outfile,
const std::string& infile);
int writeToBinary (const std::string& outfile,
std::istream& input);
int writeToBinary (std::ostream& out,
const std::string& infile);
int writeToBinary (std::ostream& out,
std::istream& input);

// functions for converting into an ASCII file with hex bytes:
int readFromBinary (const std::string&
outfile,
const std::string& infile);
int readFromBinary (const std::string& outfile,
std::istream& input);
int readFromBinary (std::ostream& out,
const std::string& infile);
int readFromBinary (std::ostream& out,
std::istream& input);

// static functions for writing ordered bytes:
static std::ostream& writeLittleEndianUShort (std::ostream& out,
ushort value);
static std::ostream& writeBigEndianUShort (std::ostream& out,
ushort value);
static std::ostream& writeLittleEndianShort (std::ostream& out,
short value);
static std::ostream& writeBigEndianShort (std::ostream& out,
short value);
static std::ostream& writeLittleEndianULong (std::ostream& out,
ulong value);
static std::ostream& writeBigEndianULong (std::ostream& out,
ulong value);
static std::ostream& writeLittleEndianLong (std::ostream& out,
long value);
static std::ostream& writeBigEndianLong (std::ostream& out,
long value);
static std::ostream& writeLittleEndianFloat (std::ostream& out,
float value);
static std::ostream& writeBigEndianFloat (std::ostream& out,
float value);
static std::ostream& writeLittleEndianDouble (std::ostream& out,
double value);
static std::ostream& writeBigEndianDouble (std::ostream& out,
double value);

static std::string keyToPitchName (int key);

protected:
int m_bytesQ; // option for printing hex bytes in ASCII output.
int m_commentsQ; // option for printing comments in ASCII output.
int m_midiQ; // output ASCII data as parsed MIDI file.
int m_maxLineLength;// number of character in ASCII output on a line.
int m_maxLineBytes; // number of hex bytes in ASCII output on a line.

private:
// helper functions for reading ASCII content to conver to binary:
int processLine (std::ostream& out,
const std::string& input,
int lineNum);
int processAsciiWord (std::ostream& out,
const std::string& input,
int lineNum);
int processStringWord (std::ostream& out,
const std::string& input,
int lineNum);
int processBinaryWord (std::ostream& out,
const std::string& input,
int lineNum);
int processDecimalWord (std::ostream& out,
const std::string& input,
int lineNum);
int processHexWord (std::ostream& out,
const std::string& input,
int lineNum);
int processVlvWord (std::ostream& out,
const std::string& input,
int lineNum);
int processMidiPitchBendWord(std::ostream& out,
const std::string& input,
int lineNum);
int processMidiTempoWord (std::ostream& out,
const std::string& input,
int lineNum);

// helper functions for reading binary content to convert to ASCII:
int outputStyleAscii (std::ostream& out, std::istream& input);
int outputStyleBinary (std::ostream& out, std::istream& input);
int outputStyleBoth (std::ostream& out, std::istream& input);
int outputStyleMidi (std::ostream& out, std::istream& input);

// MIDI parsing helper functions:
int readMidiEvent (std::ostream& out, std::istream& infile,
int& trackbytes, int& command);
int getVLV (std::istream& infile, int& trackbytes);
int getWord (std::string& word, const std::string& input,
const std::string& terminators, int index);

};

} // end of namespace smf

#endif /* _BINASC_H_INCLUDED */



Loading

0 comments on commit 51f705d

Please sign in to comment.