Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Greedysky committed Jul 19, 2017
1 parent b8db03c commit ed87071
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

修改于Spek[官网地址](http://spek.cc), [Github仓库地址](https://github.com/alexkay/spek)

运行效果
![0](https://github.com/Greedysky/qt-spek/blob/master/demo.jpg?raw=true)
![0](https://github.com/Greedysky/qt-spek/blob/master/demo.jpg?raw=true)
![1](https://github.com/Greedysky/qt-spek/blob/master/demo2.jpg?raw=true)
Binary file added demo2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ int main(int argc, char *argv[])
SpekSpectrogram w;
w.show();

w.open("filePath");
w.open("F:\\KuGou\\J.Fla - Shape Of You.mp3");

return a.exec();
}
12 changes: 6 additions & 6 deletions spek-audio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ AudioFileImpl::AudioFileImpl(
this->packet.data = nullptr;
this->packet.size = 0;
this->offset = 0;
this->frame = av_frame_alloc();
this->frame = avcodec_alloc_frame();
this->buffer_len = 0;
this->buffer = nullptr;
this->frames_per_interval = 0;
Expand All @@ -207,13 +207,13 @@ AudioFileImpl::~AudioFileImpl()
av_freep(&this->buffer);
}
if (this->frame) {
av_frame_free(&this->frame);
avcodec_free_frame(&this->frame);
}
if (this->packet.data) {
this->packet.data -= this->offset;
this->packet.size += this->offset;
this->offset = 0;
av_packet_unref(&this->packet);
av_free_packet(&this->packet);
}
if (this->format_context) {
if (this->audio_stream >= 0) {
Expand Down Expand Up @@ -250,7 +250,7 @@ int AudioFileImpl::read()

for (;;) {
while (this->packet.size > 0) {
av_frame_unref(this->frame);
// avcodec_free_frame(&this->frame);
auto codec_context = this->format_context->streams[this->audio_stream]->codec;
int got_frame = 0;
int len = avcodec_decode_audio4(codec_context, this->frame, &got_frame, &this->packet);
Expand Down Expand Up @@ -318,15 +318,15 @@ int AudioFileImpl::read()
this->packet.data -= this->offset;
this->packet.size += this->offset;
this->offset = 0;
av_packet_unref(&this->packet);
av_free_packet(&this->packet);
}

int res = 0;
while ((res = av_read_frame(this->format_context, &this->packet)) >= 0) {
if (this->packet.stream_index == this->audio_stream) {
break;
}
av_packet_unref(&this->packet);
av_free_packet(&this->packet);
}
if (res < 0) {
// End of file or error.
Expand Down
2 changes: 1 addition & 1 deletion spek-palette.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static uint32_t mono(double level)
return (v << 16) + (v << 8) + v;
}

uint32_t spek_palette(enum palette palette, double level) {
uint32_t spek_palette(Palette palette, double level) {
switch (palette) {
case PALETTE_SPECTRUM:
return spectrum(level);
Expand Down
6 changes: 3 additions & 3 deletions spek-palette.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

#include <stdint.h>

enum palette {
typedef enum palette {
PALETTE_SPECTRUM,
PALETTE_SOX,
PALETTE_MONO,
PALETTE_COUNT,
PALETTE_DEFAULT = PALETTE_SOX,
};
}Palette;

uint32_t spek_palette(enum palette palette, double level);
uint32_t spek_palette(Palette palette, double level);

#endif
2 changes: 1 addition & 1 deletion spek-spectrogram.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ SpekSpectrogram::SpekSpectrogram(QWidget *parent) :
window_function(WINDOW_DEFAULT),
duration(0.0),
sample_rate(0),
palette(PALETTE_DEFAULT),
palette(PALETTE_SPECTRUM),
prev_width(-1),
fft_bits(FFT_BITS),
urange(URANGE),
Expand Down
4 changes: 2 additions & 2 deletions spek-spectrogram.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SpekSpectrogram : public QWidget
inline QImage *getPaintImage() { return &image; }
inline int getURange() const { return urange; }
inline int getLRange() const { return lrange; }
enum palette getPalette() const { return palette; }
Palette getPalette() const { return palette; }

private:
void paintEvent(QPaintEvent *event);
Expand All @@ -46,7 +46,7 @@ class SpekSpectrogram : public QWidget
QString desc;
double duration;
int sample_rate;
enum palette palette;
Palette palette;
QImage palette_image;
QImage image;
int prev_width;
Expand Down

0 comments on commit ed87071

Please sign in to comment.