Creating a drum track
Let's buckle up and do this project! Create a new Qt Widgets Application project named ch11-drum-machine
. As usual, add the CONFIG += c++14
in ch11-drum-machine.pro
.
Now create a new C++ class named SoundEvent
. Here is SoundEvent.h
stripped from its functions:
#include <QtGlobal> class SoundEvent { public: SoundEvent(qint64 timestamp = 0, int soundId = 0); ~SoundEvent(); qint64 timestamp; int soundId; };
This class contains only two public members:
timestamp
: Aqint64
(long long
type) that contains the current time of theSoundEvent
in milliseconds since the beginning of the tracksoundId
: The ID of the sound that has been played
In recording mode, each time the user plays a sound, a SoundEvent
is created with the appropriate ...
Get Mastering Qt 5 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.