-
Notifications
You must be signed in to change notification settings - Fork 0
/
music_generator.h
44 lines (33 loc) · 899 Bytes
/
music_generator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (C) 2024 Michel de Boer
// License: GPLv3
#pragma once
#include "circle.h"
#include <QSoundEffect>
#include <QObject>
#include <queue>
namespace SpiralFun {
class SpiralScene;
class MusicGenerator : public QObject
{
Q_OBJECT
public:
MusicGenerator(const CircleList &circles, qreal toneDistance, int tonePlayInterval, SpiralScene* scene);
int getTonePlayInterval() const { return mTonePlayInterval; }
void playNotes();
private:
void initNotes();
void playNote(const std::unique_ptr<SpiralFun::Circle>& circle);
const CircleList& mCircles;
struct Sound
{
int mIndex;
std::unique_ptr<QSoundEffect> mSound;
};
std::vector<QString> mNotes;
qreal mNoteSize = 1.0;
std::unordered_map<Circle*, std::queue<Sound>> mSounds;
qreal mToneDistance = 25.0;
int mTonePlayInterval = 1;
SpiralScene* mScene;
};
}