Skip to content

Commit

Permalink
Changed main menu policy
Browse files Browse the repository at this point in the history
  • Loading branch information
ibsh committed Aug 8, 2011
1 parent 286bdb3 commit 45c1eb1
Show file tree
Hide file tree
Showing 79 changed files with 2,400 additions and 284 deletions.
32 changes: 32 additions & 0 deletions aboutdialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*************************************************************************
Copyright 2011 Ibrahim Sha'ath
This file is part of KeyFinder.
KeyFinder is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
KeyFinder is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with KeyFinder. If not, see <http://www.gnu.org/licenses/>.
*************************************************************************/

#include "aboutdialog.h"
#include "ui_aboutdialog.h"

AboutDialog::AboutDialog(QWidget *parent): QDialog(parent),ui(new Ui::AboutDialog){
ui->setupUi(this);
this->setWindowFlags(Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint);
}

AboutDialog::~AboutDialog(){
delete ui;
}
40 changes: 40 additions & 0 deletions aboutdialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*************************************************************************
Copyright 2011 Ibrahim Sha'ath
This file is part of KeyFinder.
KeyFinder is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
KeyFinder is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with KeyFinder. If not, see <http://www.gnu.org/licenses/>.
*************************************************************************/

#ifndef ABOUTDIALOG_H
#define ABOUTDIALOG_H

#include <QDialog>

namespace Ui {
class AboutDialog;
}

class AboutDialog : public QDialog{
Q_OBJECT
public:
explicit AboutDialog(QWidget *parent = 0);
~AboutDialog();
private:
Ui::AboutDialog *ui;
};

#endif // ABOUTDIALOG_H
82 changes: 82 additions & 0 deletions aboutdialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AboutDialog</class>
<widget class="QDialog" name="AboutDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>376</width>
<height>340</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>376</width>
<height>340</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>376</width>
<height>340</height>
</size>
</property>
<property name="windowTitle">
<string>About KeyFinder</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>KeyFinder v0.1</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>KeyFinder is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

KeyFinder is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with KeyFinder. If not, see http://www.gnu.org/licenses/.</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Copyright 2011 Ibrahim Sha'ath</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
37 changes: 31 additions & 6 deletions audiobuffer.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/*************************************************************************
Copyright 2011 Ibrahim Sha'ath
This file is part of KeyFinder.
KeyFinder is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
KeyFinder is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with KeyFinder. If not, see <http://www.gnu.org/licenses/>.
*************************************************************************/

#include "audiobuffer.h"

AudioBuffer::AudioBuffer(): buffer(0), channels(0), frameRate(0), samples(0){}
Expand All @@ -22,7 +43,7 @@ float AudioBuffer::getSample(int n) const{
if(n < samples){
return buffer[n];
}else{
std::cerr << "Attempt to get out-of-bounds sample (" << n << "/" << samples << ")" << std::endl;
qDebug("Attempt to get out-of-bounds sample (%d/%d)",n,samples);
return 0;
}
}
Expand All @@ -31,13 +52,17 @@ void AudioBuffer::setSample(int n,float x){
if(n < samples)
buffer[n] = x;
else
std::cerr << "Attempt to set out-of-bounds sample (" << n << "/" << samples << ")" << std::endl;
qDebug("Attempt to set out-of-bounds sample (%d/%d)",n,samples);
}

void AudioBuffer::addSamples(int newSamples){
//std::cerr << "Adding " << newSamples << " to " << audioSamples << " for " << audioSamples + newSamples << " total." << std::endl;
buffer.resize(samples + newSamples);
samples += newSamples;
void AudioBuffer::addSamples(int newSamples) throw (Exception){
try{
buffer.resize(samples + newSamples);
samples += newSamples;
}catch(...){
qCritical("Memory allocation failure adding %d samples to buffer of size %d",newSamples,samples);
throw Exception();
}
}

int AudioBuffer::getSampleCount() const{
Expand Down
25 changes: 24 additions & 1 deletion audiobuffer.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
/*************************************************************************
Copyright 2011 Ibrahim Sha'ath
This file is part of KeyFinder.
KeyFinder is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
KeyFinder is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with KeyFinder. If not, see <http://www.gnu.org/licenses/>.
*************************************************************************/

#ifndef AUDIOBUFFER_H
#define AUDIOBUFFER_H

#include "exception.h"

#include <QtGlobal>

#include <iostream>
Expand All @@ -15,7 +38,7 @@ class AudioBuffer{
void setFrameRate(int);
float getSample(int) const;
void setSample(int,float);
void addSamples(int);
void addSamples(int) throw (Exception);
int getSampleCount() const;
std::vector<float> buffer; // I don't want this public really, but libsndfile and libavcodec need access to buffer.front()
private:
Expand Down
56 changes: 35 additions & 21 deletions batchwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/*************************************************************************
Copyright 2011 Ibrahim Sha'ath
This file is part of KeyFinder.
KeyFinder is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
KeyFinder is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with KeyFinder. If not, see <http://www.gnu.org/licenses/>.
*************************************************************************/

#include "batchwindow.h"
#include "ui_batchwindow.h"

Expand Down Expand Up @@ -56,20 +77,6 @@ BatchWindow::~BatchWindow(){
delete ui;
}

void BatchWindow::on_actionNew_Detail_Keyfinder_triggered(){
DetailWindow* newWin = new DetailWindow(0);
newWin->show();
}

void BatchWindow::on_actionNew_Batch_Keyfinder_triggered(){
BatchWindow* newWin = new BatchWindow(0);
newWin->show();
}

void BatchWindow::on_actionClose_Window_triggered(){
this->close();
}

void BatchWindow::dragEnterEvent(QDragEnterEvent *e){
// accept only local files
if(allowDrops && e->mimeData()->hasUrls() && !e->mimeData()->urls().at(0).toLocalFile().isEmpty()){
Expand Down Expand Up @@ -200,7 +207,7 @@ void BatchWindow::analyseFile(int whichFile){
AudioFileDecoder* dec = AudioFileDecoder::getDecoder(filePath);
try{
ab = dec->decodeFile((char*)filePath.c_str());
}catch(const Exception& e){
}catch(Exception){
delete dec;
markBroken(whichFile);
return;
Expand All @@ -213,7 +220,7 @@ void BatchWindow::analyseFile(int whichFile){
Downsampler* ds = Downsampler::getDownsampler(prefs.getDFactor(),ab->getFrameRate(),prefs.getLastFreq());
try{
ab = ds->downsample(ab,prefs.getDFactor());
}catch(const Exception& e){
}catch(Exception){
delete ab;
delete ds;
markBroken(whichFile);
Expand All @@ -232,8 +239,14 @@ void BatchWindow::analyseFile(int whichFile){
for(int h=0; h<ch->getHops(); h++)
for(int b=0; b<ch->getBins(); b++)
loudness[h] += ch->getMagnitude(h,b);
Hcdf harto;
std::vector<int> changes = harto.peaks(harto.hcdf(ch,prefs),prefs);
Hcdf* hcdf = Hcdf::getHcdf(prefs);
std::vector<int> changes = hcdf->peaks(hcdf->hcdf(ch,prefs),prefs);

// batch output of keychange locations for Beatles experiment
//for(int i=1; i<changes.size(); i++) // don't want the leading zero
// std::cout << filePath.substr(53) << "\t" << std::fixed << std::setprecision(2) << changes[i]*(prefs.getHopSize()/(44100.0/prefs.getDFactor())) << std::endl;
// end experiment output

changes.push_back(ch->getHops()-1);
KeyClassifier hc(prefs);
std::vector<float> trackKeys(24);
Expand All @@ -243,8 +256,9 @@ void BatchWindow::analyseFile(int whichFile){
for(int k=0; k<ch->getBins(); k++)
chroma[k] += ch->getMagnitude(j,k);
int key = hc.classify(chroma);
for(int j=changes[i]; j<changes[i+1]; j++)
trackKeys[key] += loudness[j];
if(key < 24) // ignore parts that were classified as silent
for(int j=changes[i]; j<changes[i+1]; j++)
trackKeys[key] += loudness[j];
}
delete ch;
int mostCommonKey = -1;
Expand Down Expand Up @@ -306,7 +320,7 @@ void BatchWindow::writeDetectedToGrouping(){
}
for(int r = firstRow; r <= lastRow; r++){
QTableWidgetItem* item = ui->tableWidget->item(r,COL_KEY); // only write if there's a detected key
if(item != NULL){
if(item != NULL && item->text() != "Failed"){
Metadata* md = Metadata::getMetadata(ui->tableWidget->item(r,COL_PATH)->text().toAscii().data());
md->setGrouping((ui->tableWidget->item(r,COL_KEYCODE)->text() + " " + ui->tableWidget->item(r,COL_KEY)->text()).toAscii().data());
}
Expand Down
27 changes: 23 additions & 4 deletions batchwindow.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/*************************************************************************
Copyright 2011 Ibrahim Sha'ath
This file is part of KeyFinder.
KeyFinder is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
KeyFinder is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with KeyFinder. If not, see <http://www.gnu.org/licenses/>.
*************************************************************************/

#ifndef BATCHWINDOW_H
#define BATCHWINDOW_H

Expand All @@ -15,7 +36,8 @@
#include <string>
#include <vector>

#include "detailwindow.h" // need to be able to launch other window
#include "detailwindow.h"
#include "aboutdialog.h"

#include "preferences.h"
#include "visuals.h"
Expand Down Expand Up @@ -66,9 +88,6 @@ class BatchWindow : public QMainWindow{
private slots:
void fileFinished();
void fileDropFinished();
void on_actionNew_Detail_Keyfinder_triggered();
void on_actionNew_Batch_Keyfinder_triggered();
void on_actionClose_Window_triggered();
void on_runBatchButton_clicked();
void copySelectedFromTableWidget();
void writeDetectedToGrouping();
Expand Down
Loading

0 comments on commit 45c1eb1

Please sign in to comment.