Skip to content

Instantly share code, notes, and snippets.

Avatar

Pedro López-Cabanillas pedrolcl

  • Barcelona, Spain
View GitHub Profile
@pedrolcl
pedrolcl / testnativefilters.cpp
Created Apr 1, 2022
Native Event Filters for Keyboard Events in C++ Qt Application
View testnativefilters.cpp
/* 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 Apr 13, 2021
integration of uchardet with QTextCodec - codec names dont always match
View CMakeLists.txt
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 Mar 5, 2021
FluidSynth Soundfont Instruments enumeration - An example of using fluidsynth2 in C
View CMakeLists.txt
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 / CMakeLists.txt
Last active Jul 31, 2021
FluidSynth Enum Settings - An example of using fluidsynth in C++
View CMakeLists.txt
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 / keysig.c
Created May 14, 2020
Prints the key signature from the corresponding SMF meta-event values
View keysig.c
#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]);
View movablelabel.cpp
#include <QLabel>
#include <QMouseEvent>
#include <QMainWindow>
#include <QApplication>
class MovableLabel : public QLabel
{
public:
MovableLabel(QWidget* parent = nullptr): QLabel(parent)
{
View testpygame.py
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)
View gist:543c01b9a812bca4293e2c4f44cab1c9
// 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 Jan 21, 2019
Convert Linux keyboard events into ALSA sequencer events
View input2seq.c
/*
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"
@pedrolcl
pedrolcl / fluidsynth_instr.c
Last active Apr 2, 2022
List instrument names from any SF2 soundfont file, using the FluidSynth 1 API. (doesn't compile with FluidSynth 2.x)
View fluidsynth_instr.c
/* 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
*