Skip to content

Commit

Permalink
fixed notepad not opening on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Palomarrrr authored Mar 24, 2022
1 parent 517fe67 commit f844382
Showing 1 changed file with 69 additions and 38 deletions.
107 changes: 69 additions & 38 deletions BezierSV.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,46 @@
#include <limits.h>
#include <math.h>
#include <gtk/gtk.h>
#include <strings.h>

GtkWidget *mainWindow, *outptWindow, *outptBox, *entryStartTime, *entryEndTime, *entryBezP1, *entryBezP4, *entryBezP2, *entryBezP2x, *entryBezP3, *entryBezP3x, *entryBPM, *entrySnap, *startButton, *label, *label2, *vbox1, *hbox1, *hbox2, *hbox3, *label3, *hbox4, *hbox5;

int getDenom(char *snapping){
float snap;
char *snapChar[2];
char *token;
int i = 0;

while((token = strtok_r(snapping, "/", &snapping))) {
snapChar[i] = token;
i++;
}

snap = atof(snapChar[1]);

return snap;
}

int timeToTick(char *time){
int tick;
char *token;

char *ticks[3];
int n = 0;
while((token = strtok_r(time, ":;", &time))) {
ticks[n] = token;
n++;
}

tick = atoi(ticks[2]);
int tickS = atoi(ticks[1]);
int tickM = atoi (ticks[0]);

tick = tick + (tickS * 1000);
tick = tick + (tickM * 60000);

return tick;
}

float bezSv(GtkWidget *widget, gpointer data) {
float bezPy[4], bezPx[2];
Expand All @@ -20,10 +55,12 @@ float bezSv(GtkWidget *widget, gpointer data) {
bezPx[1] = atof((char *)gtk_entry_get_text(GTK_ENTRY(entryBezP3x)));


float startTk = atof((char *)gtk_entry_get_text(GTK_ENTRY(entryStartTime)));
float endTk = atof((char *)gtk_entry_get_text(GTK_ENTRY(entryEndTime)));
//float startTk = atof((char *)gtk_entry_get_text(GTK_ENTRY(entryStartTime)));
float startTk = timeToTick((char *)gtk_entry_get_text(GTK_ENTRY(entryStartTime)));
//float endTk = atof((char *)gtk_entry_get_text(GTK_ENTRY(entryEndTime)));
float endTk = timeToTick((char *)gtk_entry_get_text(GTK_ENTRY(entryEndTime)));
float BPM = atof((char *)gtk_entry_get_text(GTK_ENTRY(entryBPM)));
int snap = atoi((char *)gtk_entry_get_text(GTK_ENTRY(entrySnap)));
float snap = getDenom((char *)gtk_entry_get_text(GTK_ENTRY(entrySnap)));

double incTk = 60000.0 / snap / BPM;

Expand All @@ -44,30 +81,24 @@ float bezSv(GtkWidget *widget, gpointer data) {
long double currentTk = slope * currentPt + startTk;
long double actTk = slope * i + startTk;

//debugging
printf("%lf,%Lf,%Lf,%lf,%lf\n", round(currentTk), sv, currentPt, incTk, floor(actTk));

currentTk = currentTk + (actTk - currentTk);

fprintf(outputFile, "%0.lf,%Lf,4,1,0,100,0,0\n", floor(currentTk), -100.0 / sv);




}

fclose(outputFile);

#ifdef _WIN32
system("notepad\\SV.txt\\");
system("notepad SV.txt");
#elif _WIN64
system("notepad\\SV.txt\\");
system("notepad SV.txt");
#elif __linux__
system("gedit SV.txt");
#elif __APPLE__
printf("wtf");
printf("Get a real pc");
#else
printf("wtf");
printf("wtf are you using???????");
#endif

}
Expand All @@ -78,36 +109,34 @@ int main(int argc, char *argv[]) {
gtk_init(&argc, &argv);

mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
outptWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);

entryStartTime = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(entryStartTime), "Start Tick");
gtk_entry_set_text(GTK_ENTRY(entryStartTime), "x:xx:xxx");
entryEndTime = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(entryEndTime), "End Tick");
gtk_entry_set_text(GTK_ENTRY(entryEndTime), "x:xx:xxx");

entryBezP1 = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(entryBezP1), "Start");
entryBezP2 = gtk_entry_new();
entryBezP2x = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(entryBezP2), "Ctrl 1");
gtk_entry_set_text(GTK_ENTRY(entryBezP2x), "Ctrl 1 x (between 0 and 1)");
gtk_entry_set_text(GTK_ENTRY(entryBezP2x), "Ctrl 1 X");
entryBezP3 = gtk_entry_new();
entryBezP3x = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(entryBezP3), "Ctrl 2");
gtk_entry_set_text(GTK_ENTRY(entryBezP3x), "Ctrl 2 x val (between 0 and 1)");
gtk_entry_set_text(GTK_ENTRY(entryBezP3x), "Ctrl 2 X");
entryBezP4 = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(entryBezP4), "End");

entryBPM = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(entryBPM), "BPM");
entrySnap = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(entrySnap), "1/x (enter x)");
entrySnap = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entrySnap), "1/x");

label = gtk_label_new("--Ticks->");
label2 = gtk_label_new("--General->");
label3 = gtk_label_new("--Controls->");
label = gtk_label_new("--Time->");
label2 = gtk_label_new("--SV->");
label3 = gtk_label_new("--Ctrls->");

startButton = gtk_button_new_with_mnemonic("Start");
startButton = gtk_button_new_with_label("Start");


vbox1 = gtk_vbox_new(1, 0);
Expand All @@ -124,24 +153,24 @@ int main(int argc, char *argv[]) {
gtk_box_pack_start(GTK_BOX(vbox1), hbox4, 0, 0, 0);
gtk_box_pack_start(GTK_BOX(vbox1), hbox5, 0, 0, 0);

gtk_box_pack_start(GTK_BOX(hbox1), entryStartTime, 0, 0, 0);
gtk_box_pack_start(GTK_BOX(hbox1), label, 0, 0, 0);
gtk_box_pack_start(GTK_BOX(hbox1), entryEndTime, 0, 0, 0);
gtk_box_pack_start(GTK_BOX(hbox1), entryStartTime, 0, 1, 5);
gtk_box_pack_start(GTK_BOX(hbox1), label, 0, 1, 0);
gtk_box_pack_start(GTK_BOX(hbox1), entryEndTime, 0, 1, 5);

gtk_box_pack_start(GTK_BOX(hbox2), entryBezP1,0 ,0 ,0);
gtk_box_pack_start(GTK_BOX(hbox2), label2, 0, 0, 0);
gtk_box_pack_start(GTK_BOX(hbox2), entryBezP4, 0, 0, 0);
gtk_box_pack_start(GTK_BOX(hbox2), entryBezP1, 0, 1, 5);
gtk_box_pack_start(GTK_BOX(hbox2), label2, 0, 1, 0);
gtk_box_pack_start(GTK_BOX(hbox2), entryBezP4, 0, 1, 5);

gtk_box_pack_start(GTK_BOX(hbox3), entryBezP2, 0, 0, 0);
gtk_box_pack_start(GTK_BOX(hbox3), entryBezP2x, 0, 0, 0);
gtk_box_pack_start(GTK_BOX(hbox3), label3, 0, 0, 0);
gtk_box_pack_start(GTK_BOX(hbox3), entryBezP3, 0, 0, 0);
gtk_box_pack_start(GTK_BOX(hbox3), entryBezP3x, 0, 0, 0);
gtk_box_pack_start(GTK_BOX(hbox3), entryBezP2, 1, 1, 5);
gtk_box_pack_start(GTK_BOX(hbox3), entryBezP2x, 1, 1, 5);
gtk_box_pack_start(GTK_BOX(hbox3), label3, 1, 1, 0);
gtk_box_pack_start(GTK_BOX(hbox3), entryBezP3, 1, 1, 5);
gtk_box_pack_start(GTK_BOX(hbox3), entryBezP3x, 1, 1, 5);

gtk_box_pack_start(GTK_BOX(hbox4), entryBPM, 0, 0, 0);
gtk_box_pack_start(GTK_BOX(hbox4), entrySnap, 0, 0, 0);
gtk_box_pack_start(GTK_BOX(hbox4), entryBPM, 0, 0, 5);
gtk_box_pack_start(GTK_BOX(hbox4), entrySnap, 0, 0, 5);

gtk_box_pack_start(GTK_BOX(hbox5), startButton, 0, 0, 0);
gtk_box_pack_start(GTK_BOX(hbox5), startButton, 0, 0, 5);

g_signal_connect(mainWindow, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(startButton, "clicked", G_CALLBACK(bezSv), NULL);
Expand All @@ -150,6 +179,8 @@ int main(int argc, char *argv[]) {


gtk_widget_show_all(mainWindow);
gtk_window_resize(GTK_WINDOW(mainWindow), 200, 200);

gtk_main();
return 0;
}

0 comments on commit f844382

Please sign in to comment.