Skip to content

Instantly share code, notes, and snippets.

View pedrolcl's full-sized avatar

Pedro López-Cabanillas pedrolcl

  • Barcelona, Spain
View GitHub Profile
@pedrolcl
pedrolcl / fluidsynth_instr.c
Last active April 2, 2022 03:42
List instrument names from any SF2 soundfont file, using the FluidSynth 1 API. (doesn't compile with FluidSynth 2.x)
/* FluidSynth Instruments - An example of using fluidsynth
*
* This code is in the public domain.
*
* To compile:
* gcc -o fluidsynth_instr fluidsynth_instr.c -lfluidsynth
*
* To run
* fluidsynth_instr soundfont
*
@pedrolcl
pedrolcl / testnativefilters.cpp
Created April 1, 2022 08:42
Native Event Filters for Keyboard Events in C++ Qt Application
/* Native Event Filters for Keyboard Events
* Copyright © 2022 Pedro López-Cabanillas
*
* testnativefilters.pro:
* TEMPLATE = app
* QT += core gui widgets
*
* SOURCES += \
* testnativefilters.cpp
*
@pedrolcl
pedrolcl / CMakeLists.txt
Last active July 31, 2021 20:04
FluidSynth Enum Settings - An example of using fluidsynth in C++
cmake_minimum_required(VERSION 3.5)
project(fluidenums LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this was the old method before modernization, using pkg-config
# find_package ( PkgConfig REQUIRED )
# pkg_check_modules ( FLUIDSYNTH REQUIRED IMPORTED_TARGET fluidsynth )
#if (FLUIDSYNTH_FOUND)
@pedrolcl
pedrolcl / CMakeLists.txt
Last active April 13, 2021 18:26
integration of uchardet with QTextCodec - codec names dont always match
cmake_minimum_required(VERSION 3.14)
project(integrate_uchardet LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
@pedrolcl
pedrolcl / CMakeLists.txt
Last active March 5, 2021 22:24
FluidSynth Soundfont Instruments enumeration - An example of using fluidsynth2 in C
cmake_minimum_required(VERSION 3.5)
project(instenum LANGUAGES C)
find_package ( PkgConfig REQUIRED )
pkg_check_modules ( FLUIDSYNTH REQUIRED IMPORTED_TARGET fluidsynth )
if (FLUIDSYNTH_FOUND)
add_executable(instenum fluidsynth_inst2.c)
target_link_libraries ( instenum PRIVATE PkgConfig::FLUIDSYNTH )
endif ()
@pedrolcl
pedrolcl / keysig.c
Created May 14, 2020 16:24
Prints the key signature from the corresponding SMF meta-event values
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(int argc, char* argv[])
{
if (argc == 3) {
int sf = atoi(argv[1]);
int mi = atoi(argv[2]);
#include <QLabel>
#include <QMouseEvent>
#include <QMainWindow>
#include <QApplication>
class MovableLabel : public QLabel
{
public:
MovableLabel(QWidget* parent = nullptr): QLabel(parent)
{
import pygame.midi
import time
pygame.midi.init()
#list all midi devices
for x in range( 0, pygame.midi.get_count() ):
print(x,"=",pygame.midi.get_device_info(x))
player = pygame.midi.Output(2)
@pedrolcl
pedrolcl / gist:543c01b9a812bca4293e2c4f44cab1c9
Created July 2, 2019 08:52
macOS DLS Synth SoundBankURL
// kMusicDeviceProperty_SoundBankURL since 10.5
QByteArray utf8file = fileName.toUtf8();
CFURLRef url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(utf8file.data()), utf8file.length(), false);
if (url) {
error = AudioUnitSetProperty(dls_synth, kMusicDeviceProperty_SoundBankURL, kAudioUnitScope_Global, 0, &url, sizeof(url));
CFRelease(url);
}
@pedrolcl
pedrolcl / input2seq.c
Created January 21, 2019 05:38
Convert Linux keyboard events into ALSA sequencer events
/*
compile with:
gcc -o input2seq -lasound input2seq.c
*/
#include <linux/input.h>
#include <alsa/asoundlib.h>
#include <fcntl.h>
#include <stdio.h>
//#define INPUT_DEVICE "/dev/input/by-path/platform-i8042-serio-0-event-kbd"