Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Simple performance working

  • Loading branch information...
commit 339fec4fa6010def4600c16cd847d33a29c57474 1 parent dc31fa5
@sbourdeauducq sbourdeauducq authored
Showing with 114 additions and 51 deletions.
  1. +25 −9 src/cp.c
  2. +1 −9 src/main.c
  3. +86 −31 src/performance.c
  4. +2 −2 src/performance.h
View
34 src/cp.c
@@ -15,12 +15,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <rtems.h>
#include <stdio.h>
#include <mtklib.h>
#include "performance.h"
#include "keyboard.h"
#include "ir.h"
+#include "fb.h"
#include "audio.h"
#include "midi.h"
#include "oscsettings.h"
@@ -176,10 +178,10 @@ static void cp_callback(mtk_event *e, void *arg)
open_firstpatch_window();
break;
case CP_ITEM_START:
- start_performance();
+ start_performance(false);
break;
case CP_ITEM_STARTSIMPLE:
- printf("TODO\n");
+ start_performance(true);
break;
case CP_ITEM_FILEMANAGER:
@@ -371,12 +373,26 @@ void cp_autostart()
{
char autostart[256];
- sysconfig_get_autostart(autostart);
- if(autostart[0] == 0) return;
- if(!config_load(autostart)) {
- messagebox("Autostart failed", "Unable to load the specified performance file.\nCheck the 'Autostart' section in the 'System settings' dialog box.");
- return;
+ switch(sysconfig_get_autostart_mode()) {
+ case SC_AUTOSTART_NONE:
+ break;
+ case SC_AUTOSTART_SIMPLE:
+ start_performance(true);
+ break;
+ case SC_AUTOSTART_FILE:
+ sysconfig_get_autostart(autostart);
+ if(autostart[0] == 0) {
+ messagebox("Autostart failed", "No performance file specified.");
+ fb_unblank();
+ return;
+ }
+ if(!config_load(autostart)) {
+ messagebox("Autostart failed", "Unable to load the specified performance file.\nCheck the 'Autostart' section in the 'System settings' dialog box.");
+ fb_unblank();
+ return;
+ }
+ on_config_change();
+ start_performance(false);
+ break;
}
- on_config_change();
- start_performance();
}
View
10 src/main.c
@@ -78,17 +78,9 @@
#include "flash.h"
#include "filedialog.h"
-static int has_autostart()
-{
- char autostart[256];
-
- sysconfig_get_autostart(autostart);
- return autostart[0] != 0;
-}
-
static rtems_task gui_task(rtems_task_argument argument)
{
- init_fb_mtk(has_autostart());
+ init_fb_mtk(sysconfig_get_autostart_mode() != SC_AUTOSTART_NONE);
sysconfig_set_mtk_wallpaper();
sysconfig_set_mtk_keyboard_layout();
init_input();
View
117 src/performance.c
@@ -16,9 +16,11 @@
*/
#include <assert.h>
+#include <rtems.h>
#include <stdio.h>
#include <string.h>
-#include <rtems.h>
+#include <dirent.h>
+#include <sys/stat.h>
#include <mtklib.h>
#include <keycodes.h>
@@ -42,6 +44,8 @@ struct patch_info {
static int npatches;
static struct patch_info patches[MAX_PATCHES];
+static bool simple_mode;
+static int simple_current;
static int add_patch(const char *filename)
{
@@ -141,6 +145,33 @@ static void add_osc_patches()
}
}
+#define SIMPLE_PATCHES_FOLDER "/flash/"
+
+static void add_simple_patches()
+{
+ DIR *d;
+ struct dirent *entry;
+ struct stat s;
+ char fullname[384];
+ char *c;
+
+ d = opendir(SIMPLE_PATCHES_FOLDER);
+ if(!d)
+ return;
+ while((entry = readdir(d))) {
+ if(entry->d_name[0] == '.') continue;
+ strncpy(fullname, SIMPLE_PATCHES_FOLDER, sizeof(fullname));
+ strncat(fullname, entry->d_name, sizeof(fullname));
+ lstat(fullname, &s);
+ if(!S_ISDIR(s.st_mode)) {
+ c = strrchr(entry->d_name, '.');
+ if((c != NULL) && (strcmp(c, ".fnp") == 0))
+ add_patch(fullname);
+ }
+ }
+ closedir(d);
+}
+
static int appid;
static int started;
@@ -260,27 +291,38 @@ static void event_callback(mtk_event *e, int count)
int i;
int index;
- for(i=0;i<count;i++) {
- index = -1;
- if(e[i].type == EVENT_TYPE_PRESS) {
- index = keycode_to_index(e[i].press.code);
- if(index != -1)
- index = keyboard_patches[index];
- } else if(e[i].type == EVENT_TYPE_IR) {
- index = e[i].press.code;
- index = ir_patches[index];
- } else if(e[i].type == EVENT_TYPE_MIDI) {
- if(((e[i].press.code & 0x0f00) >> 8) == midi_channel) {
- index = e[i].press.code & 0x7f;
- index = midi_patches[index];
+ index = -1;
+ if(simple_mode) {
+ for(i=0;i<count;i++) {
+ if((e[i].type == EVENT_TYPE_PRESS) && (e[i].press.code == MTK_KEY_F11)) {
+ simple_current++;
+ if(simple_current == npatches)
+ simple_current = 0;
+ index = simple_current;
+ }
+ }
+ } else {
+ for(i=0;i<count;i++) {
+ if(e[i].type == EVENT_TYPE_PRESS) {
+ index = keycode_to_index(e[i].press.code);
+ if(index != -1)
+ index = keyboard_patches[index];
+ } else if(e[i].type == EVENT_TYPE_IR) {
+ index = e[i].press.code;
+ index = ir_patches[index];
+ } else if(e[i].type == EVENT_TYPE_MIDI) {
+ if(((e[i].press.code & 0x0f00) >> 8) == midi_channel) {
+ index = e[i].press.code & 0x7f;
+ index = midi_patches[index];
+ }
+ } else if(e[i].type == EVENT_TYPE_OSC) {
+ index = e[i].press.code & 0x3f;
+ index = osc_patches[index];
}
- } else if(e[i].type == EVENT_TYPE_OSC) {
- index = e[i].press.code & 0x3f;
- index = osc_patches[index];
}
- if(index != -1)
- renderer_set_patch(patches[index].p);
}
+ if(index != -1)
+ renderer_set_patch(patches[index].p);
}
static void stop_callback()
@@ -303,7 +345,8 @@ static void refresh_callback(mtk_event *e, int count)
input_delete_callback(refresh_callback);
input_add_callback(event_callback);
mtk_cmd(appid, "l_text.set(-text \"Done.\")");
- if(!guirender(appid, patches[firstpatch].p, stop_callback))
+ if(!guirender(appid, patches[simple_mode ? simple_current : firstpatch].p,
+ stop_callback))
stop_callback();
return;
}
@@ -324,7 +367,7 @@ static void refresh_callback(mtk_event *e, int count)
static rtems_id comp_task_id;
-void start_performance()
+void start_performance(bool simple)
{
rtems_status_code sc;
@@ -332,18 +375,30 @@ void start_performance()
started = 1;
/* build patch list */
+ simple_mode = simple;
npatches = 0;
- add_firstpatch();
- if(npatches < 1) {
- messagebox("Error", "No first patch defined!\n");
- started = 0;
- fb_unblank();
- return;
+ simple_current = 0;
+ if(simple) {
+ add_simple_patches();
+ if(npatches < 1) {
+ messagebox("Error", "No patches found!\n");
+ started = 0;
+ fb_unblank();
+ return;
+ }
+ } else {
+ add_firstpatch();
+ if(npatches < 1) {
+ messagebox("Error", "No first patch defined!\n");
+ started = 0;
+ fb_unblank();
+ return;
+ }
+ add_keyboard_patches();
+ add_ir_patches();
+ add_midi_patches();
+ add_osc_patches();
}
- add_keyboard_patches();
- add_ir_patches();
- add_midi_patches();
- add_osc_patches();
/* start patch compilation task */
compiled_patches = 0;
View
4 src/performance.h
@@ -1,6 +1,6 @@
/*
* Flickernoise
- * Copyright (C) 2010 Sebastien Bourdeauducq
+ * Copyright (C) 2010, 2011 Sebastien Bourdeauducq
*
* 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
@@ -19,6 +19,6 @@
#define __PERFORMANCE_H
void init_performance();
-void start_performance();
+void start_performance(bool simple);
#endif /* __PERFORMANCE_H */
Please sign in to comment.
Something went wrong with that request. Please try again.