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 of 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: A qint64 (of the long long type) that contains the current time of the SoundEvent in milliseconds since the beginning of the track
  • soundId: The ID of the sound that has been played

In recording mode, each time the user plays a sound, a SoundEvent is created with ...

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.