-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c2c2001
Showing
24 changed files
with
21,512 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
project(prodatum) | ||
cmake_minimum_required(VERSION 2.6) | ||
|
||
SET( VER 1.1.0 ) | ||
SET( SYSEX_MAX_SIZE 138 ) | ||
SET( RINGBUFFER_WRITE 138 ) | ||
SET( RINGBUFFER_READ 512 ) | ||
SET( PATH_MAX 512 ) | ||
SET( LOG_BUFFER_SIZE 48000 ) | ||
CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/config.h.in ${CMAKE_SOURCE_DIR}/config.h ) | ||
|
||
include_directories (${prodatum_SOURCE_DIR}/include) | ||
link_directories (${prodatum_SOURCE_DIR}/lib) | ||
|
||
file (GLOB prodatum_SOURCES *.C) | ||
add_executable (prodatum ${prodatum_SOURCES}) | ||
|
||
if(WIN32) | ||
ADD_DEFINITIONS(-DWIN32) | ||
set(CMAKE_EXE_LINKER_FLAGS "-mwindows -m32 -static-libgcc -static-libstdc++") | ||
set(ADDITIONAL_LIBRARIES winmm ole32 uuid comctl32 wsock32) | ||
endif(WIN32) | ||
|
||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||
ADD_DEFINITIONS(-DOSX -DUSE_MLOCK) | ||
set(ADDITIONAL_LIBRARIES "-framework Carbon -framework ApplicationServices -framework CoreMIDI -framework CoreAudio") | ||
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||
|
||
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") | ||
ADD_DEFINITIONS(-DUSE_MLOCK) | ||
set(ADDITIONAL_LIBRARIES X11 Xft fontconfig Xinerama asound pthread) | ||
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") | ||
|
||
target_link_libraries (prodatum fltk.a portmidi_s.a ${ADDITIONAL_LIBRARIES} ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
This git version is not for public use! | ||
Does NOT WORK! | ||
This is an experimental tree. | ||
|
||
IF YOU NEED WORKING CODE, USE THE SVN VERSION | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
// This file is part of prodatum. | ||
// Copyright 2011 Jan Eidtmann | ||
// | ||
// prodatum 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. | ||
// | ||
// prodatum 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 prodatum. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
// $Id$ | ||
|
||
#ifdef HAVE_CONFIG_H | ||
# include <config.H> | ||
#endif | ||
|
||
#include <string.h> | ||
#include <errno.h> | ||
#include <fstream> | ||
#include <sys/stat.h> | ||
#include <FL/fl_ask.H> | ||
#include <stdlib.h> | ||
|
||
#include "cfg.H" | ||
#include "debug.H" | ||
|
||
// ms to wait between name requests on init and when a WAIT is received | ||
int request_delay; | ||
// colors used in ui and widgets | ||
unsigned char colors[5]; | ||
|
||
Cfg::Cfg(const char* n, int ac) | ||
{ | ||
pmesg(40, "Cfg::Cfg(%s, %d) \n", n, ac); | ||
// defaults | ||
#ifdef WINDOWS | ||
set_export_dir(getenv("USERPROFILE")); | ||
snprintf(config_dir, BUF_PATHS, "%s/prodatum", getenv("APPDATA")); | ||
#else | ||
set_export_dir(getenv("HOME")); | ||
snprintf(config_dir, BUF_PATHS, "%s/.prodatum", export_dir); | ||
#endif | ||
snprintf(config_name, 32, "%s", n); | ||
defaults.resize(NOOPTION, 0); | ||
defaults[CFG_MIDI_OUT] = -1; | ||
defaults[CFG_MIDI_IN] = -1; | ||
defaults[CFG_MIDI_THRU] = -1; | ||
defaults[CFG_CONTROL_CHANNEL] = 0; | ||
defaults[CFG_AUTOMAP] = 1; | ||
defaults[CFG_DEVICE_ID] = 0; | ||
defaults[CFG_AUTOCONNECT] = ac; | ||
defaults[CFG_SPEED] = 0; | ||
defaults[CFG_CLOSED_LOOP_UPLOAD] = 0; | ||
defaults[CFG_CLOSED_LOOP_DOWNLOAD] = 0; | ||
defaults[CFG_TOOLTIPS] = 1; | ||
defaults[CFG_KNOBMODE] = 1; | ||
defaults[CFG_CONFIRM_EXIT] = 0; | ||
defaults[CFG_CONFIRM_RAND] = 1; | ||
defaults[CFG_CONFIRM_DISMISS] = 1; | ||
defaults[CFG_SYNCVIEW] = 0; | ||
defaults[CFG_DRLS] = 1; | ||
defaults[CFG_BG] = 170; // 170 140 | ||
defaults[CFG_BG2] = 15; // 5 215 | ||
defaults[CFG_RR] = 92; // 82 68 | ||
defaults[CFG_GG] = 102; // 92 74 | ||
defaults[CFG_BB] = 97; // 87 77 | ||
defaults[CFG_COLORED_BG] = 1; | ||
defaults[CFG_SHINY_KNOBS] = 0; | ||
defaults[CFG_LOG_SYSEX_OUT] = 0; | ||
defaults[CFG_LOG_SYSEX_IN] = 0; | ||
defaults[CFG_LOG_EVENTS_OUT] = 0; | ||
defaults[CFG_LOG_EVENTS_IN] = 0; | ||
defaults[CFG_WINDOW_WIDTH] = 843; | ||
defaults[CFG_WINDOW_HEIGHT] = 615; | ||
defaults[CFG_AUDIT_IMPORT] = 1; | ||
// load config | ||
struct stat sbuf; | ||
if (stat(config_dir, &sbuf) == -1) | ||
{ | ||
|
||
if (mkdir(config_dir, S_IRWXU| S_IRWXG | S_IROTH | S_IXOTH) == -1) | ||
{ | ||
char message[BUF_MSG]; | ||
snprintf(message, BUF_MSG, | ||
"Could not create configuration directory:\n%s - %s\n", | ||
config_dir, strerror(errno)); | ||
pmesg(1, message); | ||
fl_alert("%s", message); | ||
throw 1; | ||
} | ||
} | ||
// load config | ||
option.resize(NOOPTION, 0); | ||
char config_path[BUF_PATHS]; | ||
snprintf(config_path, BUF_PATHS, "%s/%s", config_dir, config_name); | ||
std::ifstream file(config_path); | ||
if (!file.is_open()) | ||
{ | ||
//ui->message("Could not load the config,\nusing defaults."); | ||
for (int i = 0; i < NOOPTION; i++) | ||
option[i] = defaults[i]; | ||
return; | ||
} | ||
int check_file, check = 1; | ||
for (int i = 0; i < NOOPTION; i++) | ||
{ | ||
file >> option[i]; | ||
check += option[i] * ((i % 5) + 1); | ||
} | ||
// checksum | ||
file >> check_file; | ||
// get export directory | ||
char buf[BUF_PATHS]; | ||
file.getline(0, 0); | ||
file.getline(buf, BUF_PATHS); | ||
if (!file.fail()) | ||
set_export_dir(buf); | ||
file.close(); | ||
if (check_file != check) | ||
{ | ||
fl_message("Configuration updated, using default values.\n" | ||
"Sorry for the inconvenience! I've opted for a\n" | ||
"brainless but uber-fast configuration parser."); | ||
for (int i = 0; i < NOOPTION; i++) | ||
option[i] = defaults[i]; | ||
} | ||
request_delay = option[CFG_SPEED] * 25 + 25; | ||
} | ||
|
||
Cfg::~Cfg() | ||
{ | ||
pmesg(40, "Cfg::~Cfg() \n"); | ||
// save config | ||
char config_path[BUF_PATHS]; | ||
snprintf(config_path, BUF_PATHS, "%s/%s", config_dir, config_name); | ||
std::ofstream file(config_path, std::ios::trunc); | ||
if (!file.is_open()) | ||
{ | ||
fl_message("Warning:\nCould not write the config file."); | ||
return; | ||
} | ||
// calc checksum | ||
int check = 1; | ||
for (int i = 0; i < NOOPTION; i++) | ||
{ | ||
file << option[i] << " "; | ||
check += option[i] * ((i % 5) + 1); | ||
} | ||
file << check << std::endl; | ||
file << export_dir << std::endl; | ||
file.close(); | ||
} | ||
|
||
void Cfg::set_cfg_option(int opt, int value) | ||
{ | ||
pmesg(40, "Cfg::set_cfg_option(%d, %d) \n", opt, value); | ||
if (opt < NOOPTION && opt >= 0) | ||
option[opt] = value; | ||
if (opt == CFG_SPEED) | ||
request_delay = value * 25 + 25; | ||
} | ||
|
||
int Cfg::get_cfg_option(int opt) const | ||
{ | ||
pmesg(80, "Cfg::get_cfg_option(%d) \n", opt); | ||
if (opt < NOOPTION && opt >= 0) | ||
return option[opt]; | ||
return 0; | ||
} | ||
|
||
int Cfg::getset_default(int opt) | ||
{ | ||
pmesg(40, "Cfg::getset_default(%d) \n", opt); | ||
if (opt < NOOPTION && opt >= 0) | ||
{ | ||
option[opt] = defaults[opt]; | ||
return defaults[opt]; | ||
} | ||
return 0; | ||
} | ||
|
||
const char* Cfg::get_config_dir() const | ||
{ | ||
pmesg(40, "Cfg::get_config_dir() \n"); | ||
return config_dir; | ||
} | ||
|
||
const char* Cfg::get_export_dir() const | ||
{ | ||
pmesg(40, "Cfg::get_export_dir() \n"); | ||
return export_dir; | ||
} | ||
|
||
void Cfg::set_export_dir(const char* dir) | ||
{ | ||
pmesg(40, "Cfg::set_export_dir(%s) \n", dir); | ||
// add trailing slash | ||
if (dir[strlen(dir) - 1] != '/' && dir[strlen(dir) - 1] != '\\') | ||
snprintf(export_dir, BUF_PATHS, "%s/", dir); | ||
else | ||
snprintf(export_dir, BUF_PATHS, "%s", dir); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// $Id$ | ||
#ifndef CFG_H_ | ||
#define CFG_H_ | ||
/** | ||
\defgroup pd_cfg prodatum Configurations | ||
@{ | ||
*/ | ||
#ifdef WINDOWS | ||
# include <direct.h> | ||
# define mkdir(x,m) _mkdir(x) | ||
#else | ||
# define mkdir(x,m) mkdir(x,m) | ||
#endif | ||
|
||
#define SYSEX_MESSAGE_BUFFER 1024 | ||
#define RING_READ_BUFFER_SIZE 2048 | ||
#define RING_WRITE_BUFFER_SIZE SYSEX_MESSAGE_BUFFER | ||
#define MAX_ARPS 300 | ||
#define MAX_RIFFS 1000 | ||
#define LOG_BUFFER_SIZE 1000000 | ||
#include <vector> | ||
|
||
/** | ||
* Enum of config options | ||
*/ | ||
enum CONFIG | ||
{ | ||
CFG_MIDI_OUT, | ||
CFG_MIDI_IN, | ||
CFG_MIDI_THRU, | ||
CFG_CONTROL_CHANNEL, | ||
CFG_AUTOMAP, | ||
CFG_DEVICE_ID, | ||
CFG_AUTOCONNECT, | ||
CFG_SPEED, | ||
CFG_CLOSED_LOOP_UPLOAD, | ||
CFG_CLOSED_LOOP_DOWNLOAD, | ||
CFG_TOOLTIPS, | ||
CFG_KNOBMODE, | ||
CFG_CONFIRM_EXIT, | ||
CFG_CONFIRM_RAND, | ||
CFG_CONFIRM_DISMISS, | ||
CFG_SYNCVIEW, | ||
CFG_DRLS, | ||
CFG_BG, | ||
CFG_BG2, | ||
CFG_RR, | ||
CFG_GG, | ||
CFG_BB, | ||
CFG_COLORED_BG, | ||
CFG_SHINY_KNOBS, | ||
CFG_LOG_SYSEX_OUT, | ||
CFG_LOG_SYSEX_IN, | ||
CFG_LOG_EVENTS_OUT, | ||
CFG_LOG_EVENTS_IN, | ||
CFG_WINDOW_WIDTH, | ||
CFG_WINDOW_HEIGHT, | ||
CFG_AUDIT_IMPORT, | ||
NOOPTION | ||
}; | ||
|
||
/** | ||
* Enum of colors | ||
*/ | ||
enum | ||
{ | ||
BG, BG2, RR, GG, BB, DEFAULT, CURRENT, KNOBS | ||
}; | ||
|
||
/** | ||
* Configuration class. | ||
* loads, saves and manages all configuration options | ||
*/ | ||
class Cfg | ||
{ | ||
/// config name | ||
char config_name[64]; | ||
/// configuration directory | ||
char config_dir[BUF_PATHS]; | ||
/// path to export directory | ||
char export_dir[BUF_PATHS]; | ||
std::vector<int> defaults; | ||
std::vector<int> option; | ||
|
||
public: | ||
/** | ||
* CTOR parses config file | ||
*/ | ||
Cfg(const char* n, int ac); | ||
/** | ||
* DTOR saves config file | ||
*/ | ||
~Cfg(); | ||
/// returns the config directory path | ||
const char* get_config_dir() const; | ||
const char* get_export_dir() const; | ||
void set_export_dir(const char* dir); | ||
/** | ||
* updates a configuration value | ||
* @param option the parameter to update | ||
* @param value the new value for the parameter | ||
*/ | ||
void set_cfg_option(int option, int value); | ||
/** | ||
* get a configuration option | ||
* @param option parameter to get | ||
* @return parameter value | ||
*/ | ||
int get_cfg_option(int option) const; | ||
int getset_default(int option); | ||
}; | ||
|
||
#endif /* CFG_H_ */ | ||
/** @} */ |
Oops, something went wrong.