This repository was archived by the owner on Feb 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathspotifysongsarray.h
More file actions
123 lines (89 loc) · 2.69 KB
/
spotifysongsarray.h
File metadata and controls
123 lines (89 loc) · 2.69 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifndef SPOTIFYSONGSARRAY_H
#define SPOTIFYSONGSARRAY_H
#include <QList>
#include <QString>
#include <QProgressDialog>
#include <vector>
#include <QSet>
#include <QQueue>
#include <QStack>
#include <unordered_set>
// "id" "name" "album" "album_id" "artists" "artist_ids" "track_number" "disc_number"
// "explicit" "danceability" "energy" "key" "loudness" "mode" "speechiness" "acousticness"
// "instrumentalness" "liveness" "valence" "tempo" "duration_ms" "time_signature" "year" "release_date"
//***NOTES***
/*We need to find a way to update the source that is store in the Adj list object*/
struct SpotifySong
{
QString id;
QString name;
QString album;
QString albumId;
QString artists;
QString artistsId;
QString trackNumber;
QString discNumber;
bool explicitness;
double danceability;
double energy;
double loudness;
bool mode;
double speechiness;
double accousticness;
double instrumentalness;
double liveness;
double valence;
QString tempo;
int durationMs;
QString releaseDate;
QString previewUrl;
QString albumArtUrl;
QString nameby;
SpotifySong(QJsonObject obj);
SpotifySong();
//Adjacent Songs vector
QVector<SpotifySong*> adjNodes;
};
class AdjList {
//Could use this to easily get the source
//We would create this object in the mainwindow and set the source here
SpotifySong* source;
//Contains original song and all similar songs
QVector<SpotifySong*> nodeList;
QVector<SpotifySong> visited;
QVector<SpotifySong> toReturnBFS;
QVector<SpotifySong> toReturnDFS;
public:
void insert(SpotifySong newSong);
void insert(SpotifySong* newSong);
AdjList();
AdjList(SpotifySong* src);
//I dont see why we need removal capability
//Search
//How to return if we dont find anything?
SpotifySong* search(QString id);
//Update the Adj List for each song
void updateAdj();
//BFS returns a vector of most similar songs
//BFS returns a vector of most similar songs
QVector<SpotifySong>& BFS();
//DFS returns vector of similar songs
QVector<SpotifySong>& DFS();
//Find similarity score between source node and adj node
double simScore(SpotifySong* src, SpotifySong* adj);
//Update Adjacent Nodes (we need to create a threshold of similarity)
void clear() {
for (auto node : nodeList) {
delete node;
}
nodeList.clear();
}
};
struct SpotifySongsArray
{
AdjList graphSSA;
//SpotifySongsArray(QString filepath, QProgressDialog* dialog);
SpotifySongsArray(QJsonObject sourceSong);
//SpotifySong at(unsigned int i);
};
#endif // SPOTIFYSONGSARRAY_H