// tonalisa - software to look at overtone-structures
// Copyright (C) 2016 Dominik Schmidt-Philipp
//
// This program 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.
//
// This program 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 this program. If not, see .
//
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.LocalStorage 2.0
Item {
id: root
width: parent.width; height:parent.height
property var fr: []
property var am: []
property alias model: spectrumModel
property alias list: spectrumList
property var db;
Rectangle {
anchors.fill: parent
}
Button {
id: resetPeaks
text: "reset"
x:0; y:0
onClicked: {
peakCalculator.resetPeaks()
}
}
Button {
id: rememberSpectrum
x:80; y:0
text: "save spectrum"
onClicked: {
var now = new Date();
var peaks = catalog.peaks;
var freqs = [];
var amps = [];
for (var i in peaks) {
if(!(i%2)){
freqs[Math.floor(i/2)] = peaks[i];
} else {
amps[Math.floor(i/2)] = peaks[i];
}
}
spectrumList.model.append({
"name":"random-"+Qt.formatDateTime(now,"yyMMdd HH:mm"),
"baseFreq":peaks[0],
"mode":"frequencies",
"freq":JSON.stringify(freqs),
"amp" :JSON.stringify(amps)
});
spectrumList.currentIndex = spectrumModel.count-1
}
}
Button {
id: deleteSpectrum
text: "delete"
anchors.right:parent.right;
onClicked: {
spectrumList.model.remove(spectrumList.currentIndex)
}
}
Item {
id:entryEdit
x:2;y:30
width:parent.width/2-4
height:parent.height-40
Rectangle {
anchors.fill:parent
color:"#ffffff"
}
TextField {
id:sEname
width:parent.width-5
}
}
function initDatabase() {
db = LocalStorage.openDatabaseSync(
"ExtendedFrequencyToolDB",
"0.2",
"Scales and Spectra",
100000)
db.transaction( function(tx) {
console.log("... create 'spectra' table")
tx.executeSql(
'CREATE TABLE IF NOT EXISTS spectra('
+'id INTEGER,'
+'name TEXT,'
+'baseFreq REAL,'
+'mode TEXT,'
+'freq TEXT,'
+'amp TEXT)'
)
});
}
function storeData() {
if(!db) { return; }
db.transaction( function(tx) {
for (var i=0;i 0 ) {
for ( var i=0;i