-
Notifications
You must be signed in to change notification settings - Fork 0
/
musicreader.cpp
72 lines (66 loc) · 2.29 KB
/
musicreader.cpp
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
#include <cmath>
#include <iostream>
#include <opencv2/opencv.hpp>
#include <QQuickItem>
#include <QQuickItemGrabResult>
#include <QUrl>
#include <musicreader.h>
#include <pipeline.h>
MusicReader::MusicReader(QObject *parent) : QObject(parent)
{
}
void MusicReader::readSong(QUrl url) {
std::cout << "entered MusicReader::readSong" << std::endl;
QString s = url.toString();
std::string stdstring = s.toStdString();
const char *cstr = stdstring.c_str();
cstr += 7;
Song song = readImage(cstr);
emit songRead(song);
// auto grab_result = image_view->grabToImage();
// connect(grab_result.data(), &QQuickItemGrabResult::ready, [=]() {
// QImage image = grab_result->image();
// cv::Mat cv_image(image.height(), image.width(), CV_8UC3);
// std::cout << image.height() << ", " << image.width() << std::endl;
// std::cout << cv_image.rows << ", " << cv_image.cols << std::endl;
//
// for (int x = 0; x < image.width(); ++x)
// for (int y = 0; y < image.height(); ++y) {
// QRgb qcolor = image.pixel(x, y);
// int blue = qcolor & 0xFF;
// int green = (qcolor >> 8) & 0xFF;
// int red = (qcolor >> 16) & 0xFF;
// cv::Vec3b cv_color(red, green, blue);
// int new_x = std::max(x - 180, 0);
// cv_image.at<cv::Vec3b>(y, (int)((float)new_x)) = cv_color;
// }
//
// Song song = readImage(cv_image);
// std::cout << "Song read!" << std::endl;
// emit songRead(song);
// });
// Song song {
// Chord { Note::quarter(6) },
// Chord { Note::quarter(5) },
// Chord { Note::half(4) },
//
// Chord { Note::quarter(6) },
// Chord { Note::quarter(5) },
// Chord { Note::half(4) },
//
// Chord { Note::eigth(4) },
// Chord { Note::eigth(4) },
// Chord { Note::eigth(4) },
// Chord { Note::eigth(4) },
// Chord { Note::eigth(5) },
// Chord { Note::eigth(5) },
// Chord { Note::eigth(5) },
// Chord { Note::eigth(5) },
//
// Chord { Note::quarter(6) },
// Chord { Note::quarter(5) },
// Chord { Note::half(4) },
// };
// std::cout << "Song read!" << std::endl;
// emit songRead(song);
}