Skip to main content

Posts

Showing posts from February, 2025

C++ : a nasty bug

It took me 2 days to figure out this bug in C++. The context I use ncurses and I want to manage several windows. I created a class (Window) with all the methods I need. class Window { private: WINDOW *win; ... public: ... } No issue here. To store my objects, I used a vector of pointers: std::vector<Window*> Windows; The bug I want to create 2 windows, so I did the following: Window *A = new Window(...); // Instantiate the class Window, implicitely calling the constructor Windows.push_back(*A); // Adding object A to the vectors Window *B = new Window(...); // New instantiation Windows.push_back(*B); // Adding object B to the vectors The bug was here: when I pushed back the second object (B), the memory manager decided to reallocate the vectors, because vectors must be contiguous. Doing so implicitely called the destructor of the first object; the window A disappeared. Possible solutions Reserve memory for the vectors Wind...

MIDI dump of Yamaha TX816

Abstract I own two Yamaha TX816 and I need to dump and reorganize the patches. My computer runs on Ubuntu 24.04, the MIDI interface is E-MU XMIDI 1X1. Part 1 - dumping Using Bladesk Librarian A fantastic librarian working directly in your browser: https://bladesk.github.io/DX7II-Librarian/ . It works well with my Yamaha DX7 MK1, but failed to receive dumps from the TX816. Using ALSA command amidi This simple command comes with ALSA and runs into a terminal (CTRL+ALT+T to open a terminal). QJackCtl must be installed first: $ sudo apt install qjackctl $ amidi -l Dir Device Name IO hw:2,0,0 E-MU XMidi1X1 Midi In $ amidi --port=hw:2,0,0 --receive=TX816B-module1.syx cannot open port "hw:2,0,0": Device or resource busy What's going on? First, let's check the system calls: $ sudo strace amidi --port=hw:2,0,0 --receive=TX816B-module1.syx ... openat(AT_FDCWD, "/dev/snd/controlC2", O_RDWR|O_CLOEXEC) = 4 ioctl(4, SNDRV_CTL_IOCTL_PVERSION, 0x7f...