+++ /dev/null
-#include "mainwindow.h"
-
-MainWindow::MainWindow(QWidget *parent):QMainWindow(parent)
-{
- topLayout = new QVBoxLayout;
-
- centralWindow = new QWidget(this);
- setCentralWidget(centralWindow);
- centralWindow->setLayout(topLayout);
-
- tracker = new TrackerWindow(centralWindow);
- topLayout->addWidget(tracker);
-
- resize(600,600);
-}
-
-MainWindow::~MainWindow()
-{
-}
-
-
+++ /dev/null
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QWidget>
-#include <QMainWindow>
-#include <QVBoxLayout>
-#include <QHBoxLayout>
-#include "trackerwindow.h"
-
-class MainWindow: public QMainWindow
-{
- Q_OBJECT
-
- public:
- MainWindow(QWidget *parent);
- ~MainWindow();
-
- private:
- QWidget *centralWindow;
- TrackerWindow *tracker;
- QVBoxLayout *topLayout;
-};
-
-#endif
-
float vol = ((cur_trk->notes[cur_row])>>4) * 0.125f;
note+=trans;
- uint8 j = last_voice_used;
- last_voice_used = (last_voice_used + 1) % NUM_VOICES;
- memset(&voices[j], 0, sizeof(Voice));
- voices[j].pitch = detune(440.0f,note-21,0);
- voices[j].pos = buf_start;
- voices[j].ins = &song->instrument_data[cur_trk->instrument];
- voices[j].vol = vol;
- voices[j].active = 1;
+ memset(&voices[i], 0, sizeof(Voice));
+ voices[i].pitch = detune(440.0f,note-21,0);
+ voices[i].pos = buf_start;
+ voices[i].ins = &song->instrument_data[cur_trk->instrument];
+ voices[i].vol = vol;
+ voices[i].active = 1;
}
}
}
--- /dev/null
+#!/bin/bash
+gnuplot << EOF
+set samples 3000
+plot [0:10][-0.1:1.1] (1 -(1/(1+exp(-$1*(x-($2 / 10.0)))))) * (1 - (1/(1+exp(-$3*(x-($4 / 10.0))))))
+
+pause mouse keypress
+EOF
--- /dev/null
+#!/bin/bash
+gnuplot << EOF
+set samples 3000
+plot [0:10][-0.1:1.1] 1 - (1/(1+exp(-$1*(x-($2 / 10.0)))))
+pause mouse keypress
+EOF
int iPC=0; // instrument program counter
int wave=0;
- while (1) {
+ for (;;) {
uint8 ins = v->ins[iPC++];
uint8 op1 = v->ins[iPC++];
uint8 op2 = v->ins[iPC++];
//printf("wave %d, ins=%d (%d, %d)\n", wave, ins, op1, op2);
for (int i=0; i<len; i++) {
float time=(v->pos+i)*invSAMPLE_RATE;
- float global_time = current_time+i*invSAMPLE_RATE;
+ //float global_time = current_time+i*invSAMPLE_RATE;
switch (ins) {
case CONST:
- {
- float value = ((int8) op1) + ((int8) op2/100.0);
- v->waves[wave][i] = value;
- break;
- }
-
+ {
+ // op1: integer part, op2: decimal part * 100
+ float value = ((int8) op1) + ((int8) op2/100.0);
+ v->waves[wave][i] = value;
+ break;
+ }
+
case SINE:
- {
- // op1: signed coarse detune, op2: use global time
- float pitch = detune(v->pitch, (int8) op1, 0);
- if (op2)
- v->waves[wave][i] = sinf(pitch*TWOPI*global_time);
- else
- v->waves[wave][i] = sinf(pitch*TWOPI*time);
- break;
- }
-
+ {
+ // op1: signed coarse detune, op2: phase (0-255)
+ float pitch = detune(v->pitch, (int8) op1, 0);
+ v->waves[wave][i] = sinf(pitch*TWOPI*time+op2*PI/255.0f);
+ //if (op2)
+ // v->waves[wave][i] = sinf(pitch*TWOPI*global_time);
+ //else
+ // v->waves[wave][i] = sinf(pitch*TWOPI*time);
+ break;
+ }
+
case SQUARE:
- {
- float pitch = detune(v->pitch, (int8) op1, 0);
- float pw = op2/100.0f;
- float period = 1.0f/pitch;
- if (fmodf(time, period) > (period*pw))
- v->waves[wave][i] = 1.0f;
- else
- v->waves[wave][i] = -1.0f;
- break;
- }
+ {
+ // op1: signed coarse detune, op2: pulse width (%)
+ float pitch = detune(v->pitch, (int8) op1, 0);
+ float pw = op2/100.0f;
+ float period = 1.0f/pitch;
+ if (fmodf(time, period) > (period*pw))
+ v->waves[wave][i] = 1.0f;
+ else
+ v->waves[wave][i] = -1.0f;
+ break;
+ }
case NOISE:
v->waves[wave][i] = 2.0f*(rand()/(float)RAND_MAX)-1.0f;
break;
case SUM:
- v->waves[wave][i] = v->waves[wave-op1][i]+v->waves[wave-op2][i];
- break;
+ v->waves[wave][i] = v->waves[wave-op1][i]+v->waves[wave-op2][i];
+ break;
case MUL:
- v->waves[wave][i] = v->waves[wave-op1][i]*v->waves[wave-op2][i];
- break;
-
+ v->waves[wave][i] = v->waves[wave-op1][i]*v->waves[wave-op2][i];
+ break;
+
case LPF:
case HPF:
- {
- // TODO: cutoff should be a wave
- // op1, op2: cutoff, resonance
- float cutoff = v->waves[wave-op1][i];
- float r = (op2)/5.0f;
- //printf("op1=%d, op2=%d, cutoff=%f; r=%f\n", op1, op2, cutoff, r);
-
- float input = v->waves[wave-1][i];
- float *data = (float*)v->data[wave];
- // data[0-3] == pole1..pole4
- // Arif Ove Karlsen's 24dB Ladder Approximation, 3.nov 2007
- // http://musicdsp.org/showArchiveComment.php?ArchiveID=141
- //printf("BEFORE: input=%f, pole1=%f, pole2=%f, pole3=%f, pole4=%f\n", input, data[0], data[1], data[2], data[3]);
- float rez = data[3]*r; if (rez > 1) rez = 1;
- input = input-rez;
- data[0] = data[0] + ((-data[0]+input) * cutoff);
- data[1] = data[1] + ((-data[1]+data[0]) * cutoff);
- data[2] = data[2] + ((-data[2]+data[1]) * cutoff);
- data[3] = data[3] + ((-data[3]+data[2]) * cutoff);
+ {
+ // TODO: cutoff should be a wave
+ // op1, op2: cutoff, resonance
+ float cutoff = v->waves[wave-op1][i];
+ float r = (op2)/10.0f;
+ //printf("op1=%d, op2=%d, cutoff=%f; r=%f\n", op1, op2, cutoff, r);
- if (ins == LPF)
- v->waves[wave][i] = data[3];
- else
- v->waves[wave][i] = data[3] - input;
- //printf("AFTER: input=%f, pole1=%f, pole2=%f, pole3=%f, pole4=%f\n", input, data[0], data[1], data[2], data[3]);
- break;
- }
+ float input = v->waves[wave-1][i];
+ float *data = (float*)v->data[wave];
+ // data[0-3] == pole1..pole4
+ // Arif Ove Karlsen's 24dB Ladder Approximation, 3.nov 2007
+ // http://musicdsp.org/showArchiveComment.php?ArchiveID=141
+ float rez = data[3]*r; if (rez > 1.0f) rez = 1.0f;
+ input = input-rez;
+ data[0] = data[0] + ((-data[0]+input) * cutoff);
+ data[1] = data[1] + ((-data[1]+data[0]) * cutoff);
+ data[2] = data[2] + ((-data[2]+data[1]) * cutoff);
+ data[3] = data[3] + ((-data[3]+data[2]) * cutoff);
+
+ if (ins == LPF)
+ v->waves[wave][i] = data[3];
+ else
+ v->waves[wave][i] = data[3] - input;
+ break;
+ }
case SIGMOID:
- {
- float f = (float)((int8)op1);
- float d = ((int8)op2)/10.0f;
- v->waves[wave][i] = 1.0f - 1.0f/(1.0f+expf(-f*(time-d)));
- break;
- }
-
+ {
+ float f = (float)((int8)op1);
+ float d = ((int8)op2)/10.0f;
+ v->waves[wave][i] = 1.0f - 1.0f/(1.0f+expf(-f*(time-d)));
+ break;
+ }
+
default:
goto end;
}
Song thesong={
{ // begin patterns
- {0x01, 0x01, 0x01, 0x03, 0x04, 0x02, 0x00, 0x00},
- {0x00, 0x00, 0x00, 0x03, 0x04, 0x02, 0x00, 0x00},
+ {0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00},
+ {0x01, 0x02, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x01, 0x02, 0x06, 0x06, 0x06, 0x05, 0x00, 0x00},
+ {0x01, 0x02, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00},
}, // end patterns
{ // begin txpose
- {0, -9, -5, 24, -12},
- {0, -9, -5, 24, -12},
+ {-15, 0, 0, 0, 0},
+ {-9, 0, -3, 0, 0},
+ {0, -20, 0, -5, 0},
+ {-15,0,24,0,0},
+ {-15, 0, 12, 15, 19, 24},
+ {-15, 0, 7, 11, 14, 19, 24},
}, // end txpose
{ // begin tracks
- {{0x14,0,0,0,0,0,0,0,0,0,0,0}, 0},
- {{45,0,0,45,0,0,45,0,0,45,0,0}, 46},
- {{0xF4,0x74,0x24,0xF4,0x74,0x24,0xF4,0x74,0x24,0xF4,0x74,0x24,}, 65},
- {{0xf4,0,0,0,0,0xfb,0xf4,0,0,0xf2,0,0}, 65},
+ {{0x44,0,0,0,0,0,0,0,0,0,0,0}, 19},
+ {{0,0,0,0,0,0,0x31,0,0,0,0,0}, 19},
+ {{0,0,0,0,0,0,0,0,0,0,0x21,0}, 19},
+ {{0,0,0,0x51,0,0,0,0,0,0,0,0}, 19},
+ {{0x94,0x54,0x14,0x94,0x54,0x14,0x94,0x54,0x14,0x94,0x54,0x14,}, 0},
+ {{0xf1,0,0xf1,0,0xf1,0xf1,0,0xf1,0,0xf1,0,0xf1}, 53},
}, // end tracks
{ // begin instrument data
- CONST,0,35,
- CONST,0,25,
- SUM,1,2,
- SINE,0,0,
- SQUARE,12,50,
- SINE,-12,1,
- SUM,2,3,
- SUM,1,2,
- CONST,0,13,
- MUL,1,2,
- LPF,8,10,
- LPF,10,0,
- SIGMOID,-10,5,
- SIGMOID,1,10,
- MUL,1,2,
- MUL,1,4,
- ENDI,
- // 43
- SIGMOID,12,0,
- NOISE,0,0,
+ // 0
+ SIGMOID,10,1,
+ SQUARE,0,20,
LPF,2,40,
- MUL,1,3,
- CONST,100,0,
+ MUL,1,3,
+ CONST,8,0,
MUL,1,2,
ENDI,
- //19
- SIGMOID,10,1,
+ // 19
+ SIGMOID,2,15,
+ SIGMOID,-10,6,
+ MUL,1,2,
+ SINE,-110,200,
+ CONST,0,5,
+ MUL,1,2,
+ CONST,0,10,
+ SUM,1,2,
+ NOISE,0,0,
+ LPF,2,10,
+ MUL,1,8,
+ ENDI,
+ CONST,0,30,
+ CONST,0,10,
+ SIGMOID,10,1,
SQUARE,0,20,
- LPF,2,20,
- MUL,1,3,
+ SQUARE,12,15,
+ SQUARE,-12,10,
+ SUM,1,2,
+ SUM,1,4,
+ MUL,1,6,
+ HPF,8,20,
+ LPF,10,20,
+ CONST,0,40,
+ MUL,1,2,
END,
+ // 53
}, // end instrument data
{ // begin playlist
- 1,255,
+ 0,1,2,1,3,3,3,3,3,3,3,3,3,4,4,5,5,4,4,5,5,4,4,5,5,255,
}, // end playlist
};
+++ /dev/null
-#include "trackerwindow.h"
-#include <QPainter>
-
-TrackerWindow::TrackerWindow(QWidget *parent):QWidget(parent)
-{
-}
-
-void TrackerWindow::paintEvent(QPaintEvent *event)
-{
- QPainter painter(this);
- painter.drawText(200, 200,tr("LOL WUT"));
-
-}
+++ /dev/null
-#ifndef TRACKERWINDOW_H
-#define TRACKERWINDOW_H
-
-#include <QWidget>
-#include <QPaintEvent>
-#include "song.h"
-#include "sizedtypes.h"
-
-class TrackerWindow : public QWidget
-{
- Q_OBJECT
-
- public:
- TrackerWindow(QWidget *parent);
- void setSong(Song *song) { theSong = song; }
- void setPattern(uint8 pat) { currentPattern = pat; }
-
- private:
- void paintEvent(QPaintEvent *);
- Song *theSong;
- uint8 currentPattern;
-};
-
-#endif // TRACKERWINDOW_H