Subversion Repositories svn.mios32

Compare Revisions

Ignore whitespace Rev 2634 → Rev 2635

/trunk/apps/sequencers/midibox_seq_v4_lite/Makefile
58,6 → 58,7
$(MIDIBOX_SEQ_V4_PATH)/core/seq_file_c.c \
$(MIDIBOX_SEQ_V4_PATH)/core/seq_file_gc.c \
$(MIDIBOX_SEQ_V4_PATH)/core/seq_file_bm.c \
$(MIDIBOX_SEQ_V4_PATH)/core/seq_file_presets.c \
core/seq_file_hw.c \
$(MIDIBOX_SEQ_V4_PATH)/core/seq_layer.c \
$(MIDIBOX_SEQ_V4_PATH)/core/seq_random.c \
/trunk/apps/sequencers/midibox_seq_v4/CHANGELOG.txt
22,6 → 22,29
If it's desired to permanently control the parameter layer with the selection buttons, just
press&release the Param button.
 
o It's now possible to customize the list of labels which are used during track/pattern
name and category and drum selection. After booting the new firmware, following files
will be created in the /PRESETS folder: TRKLABEL.V4P, TRKCATS.V4P and TRKDRUMS.V4P
 
Edit these files with the MIOS File browser. Uploaded changes are immediately taken
over.
 
- TRKLABEL and TRKCATS: are used in MENU->EVNT, "Trk Inst.", "Edit Name" page
(Use GP15 to select the Preset)
 
- TRKDRUMS is used on the same page when a drum track is edited (instead of a
track name we configure instrument names)
 
Special treatment: TRKDRUMS.V4P also maps MIDI notes to the drum labels.
Whenever a new preset drum is selected, the drum note will be changed accordingly.
This allows you to fully customize drum maps.
 
The first 16 drums are taken by default whenever a drum track is initialized, and the
remaining drums in the list can be optionally selected to replace on of the 16
drum instruments.
 
- TRKLABEL and TRKCATS are also used when a pattern is saved
 
o New option 9/33 allows to unmute tracks on pattern changes
 
o New option 14/33 allows to change the steps of the current selected view only
/trunk/apps/sequencers/midibox_seq_v4/core/seq_layer.c
102,8 → 102,8
};
 
 
// initial drum notes (order must match with preset_dum in seq_label.c)
static const u8 seq_layer_preset_table_drum_notes[16] = {
// initial drum notes (can be customized in /PRESETS/TRKDRUMS.V4P)
static u8 seq_layer_preset_table_drum_notes[16] = {
0x24, // BD
0x26, // SD
0x2a, // CH
253,6 → 253,31
 
 
/////////////////////////////////////////////////////////////////////////////
// This function allows to change the default drum note
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_LAYER_PresetDrumNoteSet(u8 num, u8 note)
{
if( num >= 16 ) {
return -1; // invalid note
}
 
seq_layer_preset_table_drum_notes[num] = note;
 
return 0; // no error
}
 
 
s32 SEQ_LAYER_PresetDrumNoteGet(u8 num)
{
if( num >= 16 ) {
return -1; // invalid note
}
 
return seq_layer_preset_table_drum_notes[num];
}
 
 
/////////////////////////////////////////////////////////////////////////////
// This function returns a string to the event mode name (5 chars)
/////////////////////////////////////////////////////////////////////////////
// Note: newer gcc versions don't allow to return a "const" parameter, therefore
/trunk/apps/sequencers/midibox_seq_v4/core/seq_file.c
43,6 → 43,7
#include "seq_file_s.h"
#include "seq_file_m.h"
#include "seq_file_bm.h"
#include "seq_file_presets.h"
 
#include "seq_mixer.h"
#include "seq_pattern.h"
118,6 → 119,7
status |= SEQ_FILE_M_Init(0); // mixer file access
status |= SEQ_FILE_S_Init(0); // song file access
status |= SEQ_FILE_BM_Init(0); // bookmarks file access
status |= SEQ_FILE_PRESETS_Init(0); // presets file access
 
return status;
}
135,6 → 137,8
 
// ignore status if global setup file doesn't exist
SEQ_FILE_GC_Load();
 
SEQ_FILE_PRESETS_Load();
}
 
status |= SEQ_FILE_B_LoadAllBanks(seq_file_session_name);
180,6 → 184,7
status |= SEQ_FILE_GC_Unload();
status |= SEQ_FILE_BM_Unload(0);
status |= SEQ_FILE_BM_Unload(1);
status |= SEQ_FILE_PRESETS_Unload();
status |= SEQ_FILE_HW_Unload();
 
// invalidate session
/trunk/apps/sequencers/midibox_seq_v4/core/seq_layer.h
50,6 → 50,9
extern s32 SEQ_LAYER_ResetTrackPCBankLatchedValues(void);
extern s32 SEQ_LAYER_SendPCBankValues(u8 track, u8 force, u8 send_now);
 
extern s32 SEQ_LAYER_PresetDrumNoteSet(u8 num, u8 note);
extern s32 SEQ_LAYER_PresetDrumNoteGet(u8 num);
 
extern const char *SEQ_LAYER_GetEvntModeName(seq_event_mode_t event_mode);
 
extern s32 SEQ_LAYER_GetEvntOfLayer(u8 track, u16 step, u8 layer, u8 instrument, seq_layer_evnt_t *layer_event);
/trunk/apps/sequencers/midibox_seq_v4/core/seq_file.h
83,18 → 83,24
#define SEQ_FILE_T_ERR_TRACK -228 // invalid track number
 
// used by seq_file_gc.c
#define SEQ_FILE_GC_ERR_FORMAT -140 // invalid config file format
#define SEQ_FILE_GC_ERR_READ -141 // error while reading file (exact error status cannot be determined anymore)
#define SEQ_FILE_GC_ERR_WRITE -142 // error while writing file (exact error status cannot be determined anymore)
#define SEQ_FILE_GC_ERR_NO_FILE -143 // no or invalid config file
#define SEQ_FILE_GC_ERR_FORMAT -230 // invalid config file format
#define SEQ_FILE_GC_ERR_READ -231 // error while reading file (exact error status cannot be determined anymore)
#define SEQ_FILE_GC_ERR_WRITE -232 // error while writing file (exact error status cannot be determined anymore)
#define SEQ_FILE_GC_ERR_NO_FILE -233 // no or invalid config file
 
// used by seq_file_bm.c
#define SEQ_FILE_BM_ERR_FORMAT -156 // invalid config file format
#define SEQ_FILE_BM_ERR_READ -157 // error while reading file (exact error status cannot be determined anymore)
#define SEQ_FILE_BM_ERR_WRITE -158 // error while writing file (exact error status cannot be determined anymore)
#define SEQ_FILE_BM_ERR_NO_FILE -159 // no or invalid config file
#define SEQ_FILE_BM_ERR_FORMAT -246 // invalid config file format
#define SEQ_FILE_BM_ERR_READ -247 // error while reading file (exact error status cannot be determined anymore)
#define SEQ_FILE_BM_ERR_WRITE -248 // error while writing file (exact error status cannot be determined anymore)
#define SEQ_FILE_BM_ERR_NO_FILE -249 // no or invalid config file
 
// used by seq_file_presets.c
#define SEQ_FILE_PRESETS_ERR_FORMAT -256 // invalid config file format
#define SEQ_FILE_PRESETS_ERR_READ -257 // error while reading file (exact error status cannot be determined anymore)
#define SEQ_FILE_PRESETS_ERR_WRITE -258 // error while writing file (exact error status cannot be determined anymore)
#define SEQ_FILE_PRESETS_ERR_NO_FILE -259 // no or invalid config file
 
 
/////////////////////////////////////////////////////////////////////////////
// Global Types
/////////////////////////////////////////////////////////////////////////////
/trunk/apps/sequencers/midibox_seq_v4/core/seq_ui_trkevnt.c
1476,8 → 1476,11
if( lc->event_mode == SEQ_EVENT_MODE_Drum ) {
int i;
 
for(i=0; i<16; ++i)
SEQ_LABEL_CopyPresetDrum(i, (char *)&seq_core_trk[track].name[5*i]);
for(i=0; i<16; ++i) {
u8 note = 36;
SEQ_LABEL_CopyPresetDrum(i, (char *)&seq_core_trk[track].name[5*i], &note);
SEQ_LAYER_PresetDrumNoteSet(i, note); // define new default value for drum
}
} else {
memset((char *)seq_core_trk[track].name, ' ', 80);
}
/trunk/apps/sequencers/midibox_seq_v4/core/seq_file_presets.c
New file
0,0 → 1,524
// $Id: seq_file_bm.c 2634 2019-01-05 16:51:12Z tk $
/*
* Preset Files access functions
*
* NOTE: before accessing the SD Card, the upper level function should
* synchronize with the SD Card semaphore!
* MUTEX_SDCARD_TAKE; // to take the semaphore
* MUTEX_SDCARD_GIVE; // to release the semaphore
*
* ==========================================================================
*
* Copyright (C) 2008 Thorsten Klose (tk@midibox.org)
* Licensed for personal non-commercial use only.
* All other rights reserved.
*
* ==========================================================================
*/
 
/////////////////////////////////////////////////////////////////////////////
// Include files
/////////////////////////////////////////////////////////////////////////////
 
#include <mios32.h>
 
#include <string.h>
 
#include "file.h"
#include "seq_file.h"
#include "seq_file_presets.h"
 
#include "seq_layer.h"
#include "seq_ui.h"
 
 
/////////////////////////////////////////////////////////////////////////////
// for optional debugging messages via DEBUG_MSG (defined in mios32_config.h)
/////////////////////////////////////////////////////////////////////////////
 
// Note: verbose level 1 is default - it prints error messages!
#define DEBUG_VERBOSE_LEVEL 1
 
 
/////////////////////////////////////////////////////////////////////////////
// Local definitions
/////////////////////////////////////////////////////////////////////////////
 
// in which subdirectory of the SD card are the preset files located?
// use "/" for root
// use "/<dir>/" for a subdirectory in root
// use "/<dir>/<subdir>/" to reach a subdirectory in <dir>, etc..
 
#define SEQ_PRESET_FILES_PATH "/PRESETS"
#define SEQ_PRESET_TRKLABEL_PATH SEQ_PRESET_FILES_PATH "/TRKLABEL.V4P"
#define SEQ_PRESET_TRKCATS_PATH SEQ_PRESET_FILES_PATH "/TRKCATS.V4P"
#define SEQ_PRESET_TRKDRUMS_PATH SEQ_PRESET_FILES_PATH "/TRKDRUMS.V4P"
 
 
/////////////////////////////////////////////////////////////////////////////
// Local types
/////////////////////////////////////////////////////////////////////////////
 
// file informations stored in RAM
typedef struct {
u8 num_trk_labels;
u8 num_trk_categories;
u8 num_trk_drums;
} seq_file_presets_info_t;
 
 
/////////////////////////////////////////////////////////////////////////////
// Local prototypes
/////////////////////////////////////////////////////////////////////////////
 
 
/////////////////////////////////////////////////////////////////////////////
// Local variables
/////////////////////////////////////////////////////////////////////////////
 
static seq_file_presets_info_t seq_file_presets_info;
 
static const char *default_trk_labels[] = {
"Vintage",
"Synthline",
"Bassline",
"Pads",
"Chords",
"Lovely Arps",
"Electr. Drums",
"Heavy Beats",
"Simple Beats",
"CC Tracks",
"Experiments",
"Live Played",
"Transposer"
};
 
 
static const char *default_trk_categories[] = {
"Synth",
"Piano",
"Bass",
"Drums",
"Break",
"MBSID",
"MBFM",
"Ctrl"
};
 
 
// must match with seq_layer_preset_table_drum_notes in seq_layer.c
static const char default_trk_drums[16][6] = {
" BD ",
" SD ",
" CH ",
" PH ",
" OH ",
" MA ",
" CP ",
" CY ",
" LT ",
" MT ",
" HT ",
" RS ",
" CB ",
"Smp1 ",
"Smp2 ",
"Smp3 "
};
 
 
/////////////////////////////////////////////////////////////////////////////
// Initialisation
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_FILE_PRESETS_Init(u32 mode)
{
// invalidate file info
SEQ_FILE_PRESETS_Unload();
 
return 0; // no error
}
 
 
/////////////////////////////////////////////////////////////////////////////
// Loads preset files
// Called from SEQ_FILE_CheckSDCard() when the SD card has been connected
// returns < 0 on errors
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_FILE_PRESETS_Load(void)
{
s32 status = 0;
 
SEQ_FILE_PRESETS_Unload();
 
// create default files (if they don't exist)
SEQ_FILE_PRESETS_CreateDefaults();
 
// count preset entries for each file
if( (status=SEQ_FILE_PRESETS_TrkLabel_Read(0, NULL)) > 0 ) {
seq_file_presets_info.num_trk_labels = status;
}
 
if( (status=SEQ_FILE_PRESETS_TrkCategory_Read(0, NULL)) > 0 ) {
seq_file_presets_info.num_trk_categories = status;
}
 
if( (status=SEQ_FILE_PRESETS_TrkDrum_Read(0, NULL, NULL, 1)) > 0 ) {
seq_file_presets_info.num_trk_drums = status;
}
 
return status;
}
 
 
/////////////////////////////////////////////////////////////////////////////
// Unloads preset files
// Called from SEQ_FILE_CheckSDCard() when the SD card has been disconnected
// returns < 0 on errors
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_FILE_PRESETS_Unload(void)
{
seq_file_presets_info.num_trk_labels = 0;
seq_file_presets_info.num_trk_categories = 0;
seq_file_presets_info.num_trk_drums = 0;
 
return 0; // no error
}
 
 
 
/////////////////////////////////////////////////////////////////////////////
// Returns 1 if preset file valid
// Returns 0 if preset file not valid
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_FILE_PRESETS_Valid(void)
{
return seq_file_presets_info.num_trk_labels > 0 || seq_file_presets_info.num_trk_categories > 0 || seq_file_presets_info.num_trk_drums > 0;
}
 
 
/////////////////////////////////////////////////////////////////////////////
// returns number of presets
// returns < 0 on errors (error codes are documented in seq_file.h)
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_FILE_PRESETS_TrkLabel_NumGet(void)
{
return seq_file_presets_info.num_trk_labels;
}
 
 
/////////////////////////////////////////////////////////////////////////////
// help function which reads a given preset from file (if preset_ix == 0: counts all entries)
// returns < 0 on errors (error codes are documented in seq_file.h), otherwise number of read entries
/////////////////////////////////////////////////////////////////////////////
static s32 SEQ_FILE_PRESETS_Hlp_Read(const char* filename, u8 preset_ix, char *dst, int max_len, u8 *value, u8 init_layer_preset_notes)
{
 
s32 status = 0;
file_t file;
 
if( (status=FILE_ReadOpen(&file, (char *)filename)) < 0 ) {
#if DEBUG_VERBOSE_LEVEL >= 2
DEBUG_MSG("[SEQ_FILE_PRESETS] failed to open '%s', status: %d\n", filename, status);
#endif
return SEQ_FILE_PRESETS_ERR_READ;
}
 
u32 ix = 0;
char line_buffer[128];
do {
status=FILE_ReadLine((u8 *)line_buffer, 128);
 
if( status > 1 ) {
 
if( line_buffer[0] == '#' ) {
// ignore comments
} else {
size_t len = strlen(line_buffer);
 
// comma separated?
int pos;
char *brkt = NULL;
for(pos=0; pos<len; ++pos) {
if( line_buffer[pos] == ',' ) {
line_buffer[pos] = 0;
len = pos;
brkt = &line_buffer[pos+1];
break;
}
}
 
while( (len >= 1) && (line_buffer[len-1] == ' ') ) { // strip
line_buffer[len-1] = 0;
--len;
}
 
if( len > max_len ) {
#if DEBUG_VERBOSE_LEVEL >= 1
DEBUG_MSG("[SEQ_FILE_PRESETS:%s] WARNING: line too long, %d chars max: %s", filename, max_len, line_buffer);
#endif
}
 
++ix;
 
if( ix >= 256 ) {
#if DEBUG_VERBOSE_LEVEL >= 1
DEBUG_MSG("[SEQ_FILE_PRESETS:%s] WARNING: maximum number of items (256) reached!", filename);
#endif
break;
}
 
if( dst ) {
strncpy(dst, line_buffer, max_len+1);
}
 
if( value && !brkt ) {
#if DEBUG_VERBOSE_LEVEL >= 1
DEBUG_MSG("[SEQ_FILE_PRESETS:%s] WARNING: no comma separated value found in %s", filename, line_buffer);
#endif
} else if( brkt ) {
char *next;
long l = strtol(brkt, &next, 0);
 
if( brkt == next || l < 0 || l >= 256 ) {
#if DEBUG_VERBOSE_LEVEL >= 1
DEBUG_MSG("[SEQ_FILE_PRESETS:%s] WARNING: invalid value: %s", filename, line_buffer);
#endif
} else {
if( value ) {
*value = l;
}
 
if( init_layer_preset_notes ) {
SEQ_LAYER_PresetDrumNoteSet(ix-1, l);
}
}
 
if( ix == preset_ix ) // consider that 0 will return number of all labels
break;
}
}
}
} while( status >= 1 );
 
// close file
status |= FILE_ReadClose(&file);
 
if( status < 0 ) {
#if DEBUG_VERBOSE_LEVEL >= 2
DEBUG_MSG("[SEQ_FILE_PRESETS] errors while parsing '%s'\n", filename);
#endif
return SEQ_FILE_PRESETS_ERR_FORMAT;
}
 
#if DEBUG_VERBOSE_LEVEL >= 2
if( preset_ix == 0 ) {
DEBUG_MSG("[SEQ_FILE_PRESETS] found %d items in '%s'\n", ix, filename);
}
#endif
 
return ix; // no error
}
 
 
 
/////////////////////////////////////////////////////////////////////////////
// reads a given preset from file (if preset_ix == 0: counts all entries)
// dst should be able to store up to 16 chars (15 chars + zero limiter)
// returns < 0 on errors (error codes are documented in seq_file.h), otherwise number of read entries
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_FILE_PRESETS_TrkLabel_Read(u8 preset_ix, char *dst)
{
return SEQ_FILE_PRESETS_Hlp_Read(SEQ_PRESET_TRKLABEL_PATH, preset_ix, dst, 15, NULL, 0);
}
 
 
/////////////////////////////////////////////////////////////////////////////
// returns number of presets (if preset_ix == 0: counts all entries)
// returns < 0 on errors (error codes are documented in seq_file.h), otherwise number of read entries
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_FILE_PRESETS_TrkCategory_NumGet(void)
{
return seq_file_presets_info.num_trk_categories;
}
 
/////////////////////////////////////////////////////////////////////////////
// reads a given preset from file
// returns < 0 on errors (error codes are documented in seq_file.h)
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_FILE_PRESETS_TrkCategory_Read(u8 preset_ix, char *dst)
{
return SEQ_FILE_PRESETS_Hlp_Read(SEQ_PRESET_TRKCATS_PATH, preset_ix, dst, 5, NULL, 0);
}
 
 
/////////////////////////////////////////////////////////////////////////////
// returns number of presets
// returns < 0 on errors (error codes are documented in seq_file.h)
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_FILE_PRESETS_TrkDrum_NumGet(void)
{
return seq_file_presets_info.num_trk_drums;
}
 
/////////////////////////////////////////////////////////////////////////////
// reads a given preset from file (if preset_ix == 0: counts all entries)
// returns < 0 on errors (error codes are documented in seq_file.h), otherwise number of read entries
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_FILE_PRESETS_TrkDrum_Read(u8 preset_ix, char *dst, u8 *note, u8 init_layer_preset_notes)
{
return SEQ_FILE_PRESETS_Hlp_Read(SEQ_PRESET_TRKDRUMS_PATH, preset_ix, dst, 5, note, init_layer_preset_notes);
}
 
 
 
/////////////////////////////////////////////////////////////////////////////
// creates default content of preset files
// returns < 0 on errors (error codes are documented in seq_file.h)
/////////////////////////////////////////////////////////////////////////////
extern s32 SEQ_FILE_PRESETS_CreateDefaults(void)
{
s32 status = 0;
 
char line_buffer[200];
#define FLUSH_BUFFER { status |= FILE_WriteBuffer((u8 *)line_buffer, strlen(line_buffer)); }
 
status = FILE_MakeDir(SEQ_PRESET_FILES_PATH); // create directory if it doesn't exist
status = FILE_DirExists(SEQ_PRESET_FILES_PATH);
 
if( status < 0 ) {
#if DEBUG_VERBOSE_LEVEL >= 1
DEBUG_MSG("[SEQ_FILE_PRESETS] ERROR couldn't create " SEQ_PRESET_FILES_PATH "\n");
#endif
return SEQ_FILE_PRESETS_ERR_NO_FILE;
}
 
if( FILE_FileExists(SEQ_PRESET_TRKLABEL_PATH) < 1 ) {
if( (status=FILE_WriteOpen(SEQ_PRESET_TRKLABEL_PATH, 1)) < 0 ) {
#if DEBUG_VERBOSE_LEVEL >= 1
DEBUG_MSG("[SEQ_FILE_PRESETS] Failed to open/create '" SEQ_PRESET_TRKLABEL_PATH "', status: %d\n", status);
#endif
FILE_WriteClose(); // important to free memory given by malloc
return SEQ_FILE_PRESETS_ERR_WRITE;
}
 
sprintf(line_buffer, "##########################################################\n");
FLUSH_BUFFER;
sprintf(line_buffer, "# Following labels can be selected for tracks and patterns\n");
FLUSH_BUFFER;
sprintf(line_buffer, "# Each Label can have 15 characters max!\n");
FLUSH_BUFFER;
sprintf(line_buffer, "##########################################################\n");
FLUSH_BUFFER;
sprintf(line_buffer, "\n");
FLUSH_BUFFER;
sprintf(line_buffer, "#------------->\n");
FLUSH_BUFFER;
 
int i;
u32 num = sizeof(default_trk_labels) / 4;
for(i=0; i<num; ++i) {
sprintf(line_buffer, "%s\n", default_trk_labels[i]);
FLUSH_BUFFER;
}
 
// close file
status |= FILE_WriteClose();
 
#if DEBUG_VERBOSE_LEVEL >= 1
if( status < 0 ) {
DEBUG_MSG("[SEQ_FILE_PRESETS] ERROR couldn't create " SEQ_PRESET_TRKLABEL_PATH "\n");
} else {
DEBUG_MSG("[SEQ_FILE_PRESETS] created " SEQ_PRESET_TRKLABEL_PATH " with %d items\n", num);
}
#endif
}
 
 
if( FILE_FileExists(SEQ_PRESET_TRKCATS_PATH) < 1 ) {
if( (status=FILE_WriteOpen(SEQ_PRESET_TRKCATS_PATH, 1)) < 0 ) {
#if DEBUG_VERBOSE_LEVEL >= 1
DEBUG_MSG("[SEQ_FILE_PRESETS] Failed to open/create '" SEQ_PRESET_TRKCATS_PATH "', status: %d\n", status);
#endif
FILE_WriteClose(); // important to free memory given by malloc
return SEQ_FILE_PRESETS_ERR_WRITE;
}
 
sprintf(line_buffer, "##############################################################\n");
FLUSH_BUFFER;
sprintf(line_buffer, "# Following categories can be selected for tracks and patterns\n");
FLUSH_BUFFER;
sprintf(line_buffer, "# Each category name can have 5 characters max!\n");
FLUSH_BUFFER;
sprintf(line_buffer, "##############################################################\n");
FLUSH_BUFFER;
sprintf(line_buffer, "\n");
FLUSH_BUFFER;
sprintf(line_buffer, "#--->\n");
FLUSH_BUFFER;
 
int i;
u32 num = sizeof(default_trk_categories) / 4;
for(i=0; i<num; ++i) {
sprintf(line_buffer, "%s\n", default_trk_categories[i]);
FLUSH_BUFFER;
}
 
// close file
status |= FILE_WriteClose();
 
#if DEBUG_VERBOSE_LEVEL >= 1
if( status < 0 ) {
DEBUG_MSG("[SEQ_FILE_PRESETS] ERROR couldn't create " SEQ_PRESET_TRKCATS_PATH "\n");
} else {
DEBUG_MSG("[SEQ_FILE_PRESETS] created " SEQ_PRESET_TRKCATS_PATH " with %d items\n", num);
}
#endif
}
 
 
if( FILE_FileExists(SEQ_PRESET_TRKDRUMS_PATH) < 1 ) {
if( (status=FILE_WriteOpen(SEQ_PRESET_TRKDRUMS_PATH, 1)) < 0 ) {
#if DEBUG_VERBOSE_LEVEL >= 1
DEBUG_MSG("[SEQ_FILE_PRESETS] Failed to open/create '" SEQ_PRESET_TRKDRUMS_PATH "', status: %d\n", status);
#endif
FILE_WriteClose(); // important to free memory given by malloc
return SEQ_FILE_PRESETS_ERR_WRITE;
}
 
sprintf(line_buffer, "##############################################################################\n");
FLUSH_BUFFER;
sprintf(line_buffer, "# Following drums can be selected in track instrument configuration.\n");
FLUSH_BUFFER;
sprintf(line_buffer, "# The first 16 definitions are taken by default whenever track is initialized.\n");
FLUSH_BUFFER;
sprintf(line_buffer, "# Each item contains a name and the note number (separated with a comma)\n");
FLUSH_BUFFER;
sprintf(line_buffer, "##############################################################################\n");
FLUSH_BUFFER;
sprintf(line_buffer, "\n");
FLUSH_BUFFER;
sprintf(line_buffer, "#--->,note\n");
FLUSH_BUFFER;
 
int i;
u32 num = sizeof(default_trk_drums) / 6;
for(i=0; i<num; ++i) {
sprintf(line_buffer, "%s,%d\n", default_trk_drums[i], SEQ_LAYER_PresetDrumNoteGet(i));
FLUSH_BUFFER;
}
 
// close file
status |= FILE_WriteClose();
 
#if DEBUG_VERBOSE_LEVEL >= 1
if( status < 0 ) {
DEBUG_MSG("[SEQ_FILE_PRESETS] ERROR couldn't create " SEQ_PRESET_TRKDRUMS_PATH "\n");
} else {
DEBUG_MSG("[SEQ_FILE_PRESETS] created " SEQ_PRESET_TRKDRUMS_PATH " with %d items\n", num);
}
#endif
}
 
return status;
}
/trunk/apps/sequencers/midibox_seq_v4/core/seq_file_presets.h
New file
0,0 → 1,55
// $Id: seq_file_bm.h 1205 2011-05-13 22:06:38Z tk $
/*
* Header for file functions
*
* ==========================================================================
*
* Copyright (C) 2008 Thorsten Klose (tk@midibox.org)
* Licensed for personal non-commercial use only.
* All other rights reserved.
*
* ==========================================================================
*/
 
#ifndef _SEQ_FILE_PRESETS_H
#define _SEQ_FILE_PRESETS_H
 
 
/////////////////////////////////////////////////////////////////////////////
// Global definitions
/////////////////////////////////////////////////////////////////////////////
 
 
/////////////////////////////////////////////////////////////////////////////
// Global Types
/////////////////////////////////////////////////////////////////////////////
 
 
/////////////////////////////////////////////////////////////////////////////
// Prototypes
/////////////////////////////////////////////////////////////////////////////
 
extern s32 SEQ_FILE_PRESETS_Init(u32 mode);
extern s32 SEQ_FILE_PRESETS_Load(void);
extern s32 SEQ_FILE_PRESETS_Unload(void);
 
extern s32 SEQ_FILE_PRESETS_Valid(void);
 
extern s32 SEQ_FILE_PRESETS_CreateDefaults(void);
 
extern s32 SEQ_FILE_PRESETS_TrkLabel_NumGet(void);
extern s32 SEQ_FILE_PRESETS_TrkLabel_Read(u8 preset_ix, char *dst);
 
extern s32 SEQ_FILE_PRESETS_TrkCategory_NumGet(void);
extern s32 SEQ_FILE_PRESETS_TrkCategory_Read(u8 preset_ix, char *dst);
 
extern s32 SEQ_FILE_PRESETS_TrkDrum_NumGet(void);
extern s32 SEQ_FILE_PRESETS_TrkDrum_Read(u8 preset_ix, char *dst, u8 *note, u8 init_layer_preset_notes);
 
 
/////////////////////////////////////////////////////////////////////////////
// Export global variables
/////////////////////////////////////////////////////////////////////////////
 
 
#endif /* _SEQ_FILE_PRESETS_H */
/trunk/apps/sequencers/midibox_seq_v4/core/seq_ui_trkinst.c
118,7 → 118,14
 
if( event_mode == SEQ_EVENT_MODE_Drum ) {
if( SEQ_UI_Var8_Inc(&ui_edit_preset_num_drum, 0, SEQ_LABEL_NumPresetsDrum()-1, incrementer) ) {
SEQ_LABEL_CopyPresetDrum(ui_edit_preset_num_drum, (char *)&seq_core_trk[visible_track].name[5*ui_selected_instrument]);
u8 note = 36;
SEQ_LABEL_CopyPresetDrum(ui_edit_preset_num_drum, (char *)&seq_core_trk[visible_track].name[5*ui_selected_instrument], &note);
 
SEQ_LAYER_PresetDrumNoteSet(ui_edit_preset_num_drum, note); // define new default value for drum
 
// new: also pass to CC
SEQ_CC_Set(visible_track, SEQ_CC_LAY_CONST_A1 + ui_selected_instrument, note);
for(pos=4, ui_edit_name_cursor=pos; pos>=0; --pos)
if( seq_core_trk[visible_track].name[5*ui_selected_instrument + pos] == ' ' )
ui_edit_name_cursor = pos;
/trunk/apps/sequencers/midibox_seq_v4/core/seq_terminal.c
56,6 → 56,7
#include "seq_file_t.h"
#include "seq_file_gc.h"
#include "seq_file_bm.h"
#include "seq_file_presets.h"
#include "seq_file_hw.h"
 
#include "seq_ui.h"
90,6 → 91,7
UPLOADING_FILE_GC,
UPLOADING_FILE_G,
UPLOADING_FILE_BM,
UPLOADING_FILE_PRESETS,
} uploading_file_t;
 
static uploading_file_t uploading_file;
220,7 → 222,9
static s32 TERMINAL_BrowserUploadCallback(char *filename)
{
if( filename ) {
// check for MBSEQ_HW.V4
size_t len = strlen(filename);
 
// check for various filenames
uploading_file = UPLOADING_FILE_NONE;
if( strcasecmp(filename, "/mbseq_hw.v4") == 0 )
uploading_file = UPLOADING_FILE_HW;
234,6 → 238,13
uploading_file = UPLOADING_FILE_G;
else if( strcasestr(filename, "/mbseq_bm.v4") != NULL )
uploading_file = UPLOADING_FILE_BM;
else if( strcasestr(filename, "/presets/") != 0 &&
filename[len-4] == '.' &&
(filename[len-3] == 'v' || filename[len-3] == 'V') &&
(filename[len-2] == '4') &&
(filename[len-1] == 'p' || filename[len-1] == 'P')
)
uploading_file = UPLOADING_FILE_PRESETS;
} else {
switch( uploading_file ) {
 
265,6 → 276,10
SEQ_FILE_BM_Load(seq_file_session_name, 0); // session
} break;
 
case UPLOADING_FILE_PRESETS: {
DEBUG_MSG("AUTOLOAD 'PRESETS/*.V4P'\n");
SEQ_FILE_PRESETS_Load();
} break;
 
}
}
397,9 → 412,11
out("Mass Storage Device Mode not supported by this application!");
} else if( strcmp(parameter, "tpd") == 0 ) {
SEQ_TPD_PrintString(brkt); // easter egg ;-)
#ifndef MBSEQV4L
} else if( strcmp(parameter, "lcd") == 0 ) {
SEQ_LCD_LOGO_ScreenSaver_Disable(); // ensure that screen saver disabled
SEQ_UI_Msg(SEQ_UI_MSG_USER, 2000, "From MIOS Terminal:", brkt); // could be useful?
#endif
} else if( strcmp(parameter, "set") == 0 ) {
if( (parameter = strtok_r(NULL, separators, &brkt)) ) {
if( strcmp(parameter, "router") == 0 ) {
887,7 → 904,9
out(" bookmarks: print bookmarks");
out(" router: print MIDI router info");
out(" tpd <string>: print a scrolled text on the TPD");
#ifndef MBSEQV4L
out(" lcd <string>: print a message on LCD");
#endif
out(" set router <node> <in-port> <off|channel|all> <out-port> <off|channel|all>: change router setting");
out(" set mclk_in <in-port> <on|off>: change MIDI IN Clock setting");
out(" set mclk_out <out-port> <on|off>: change MIDI OUT Clock setting");
/trunk/apps/sequencers/midibox_seq_v4/core/seq_midimp.c
231,8 → 231,11
for(j=0; j<num_steps; ++j)
SEQ_PAR_Set(track, j, 0, i, 100);
 
for(i=0; i<16; ++i)
SEQ_LABEL_CopyPresetDrum(i, (char *)&seq_core_trk[track].name[5*i]);
for(i=0; i<16; ++i) {
u8 note = 36;
SEQ_LABEL_CopyPresetDrum(i, (char *)&seq_core_trk[track].name[5*i], &note);
SEQ_LAYER_PresetDrumNoteSet(ui_edit_preset_num_drum, note); // define new default value for drum
}
} else {
SEQ_PAR_TrackInit(track, num_steps, seq_midimp_num_layers, 1);
SEQ_TRG_TrackInit(track, num_steps, seq_midimp_num_layers, 1);
/trunk/apps/sequencers/midibox_seq_v4/core/seq_label.c
18,66 → 18,13
#include <mios32.h>
#include <string.h>
 
#include "tasks.h"
 
#include "seq_label.h"
 
#include "seq_file_presets.h"
 
/////////////////////////////////////////////////////////////////////////////
// Local variables
/////////////////////////////////////////////////////////////////////////////
 
static const char preset_categories[][6] = {
" ",
"Synth",
"Piano",
"Bass ",
"Drums",
"Break",
"MBSID",
"MBFM ",
"Ctrl"
};
 
 
static const char preset_labels[][16] = {
" ",
"Vintage ",
"Synthline ",
"Bassline ",
"Pads ",
"Chords ",
"Lovely Arps ",
"Electr. Drums ",
"Heavy Beats ",
"Simple Beats ",
"CC Tracks ",
"Experiments ",
"Live Played ",
"Transposer "
};
 
 
// order must match with seq_layer_preset_table_drum_notes in seq_layer.c
static const char preset_drum[][6] = {
" BD ",
" SD ",
" CH ",
" PH ",
" OH ",
" MA ",
" CP ",
" CY ",
" LT ",
" MT ",
" HT ",
" RS ",
" CB ",
"Smp1 ",
"Smp2 ",
"Smp3 "
};
 
 
 
/////////////////////////////////////////////////////////////////////////////
// Initialisation
/////////////////////////////////////////////////////////////////////////////
92,7 → 39,7
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_LABEL_NumPresets(void)
{
return sizeof(preset_labels) / 16;
return SEQ_FILE_PRESETS_TrkLabel_NumGet()+1;
}
 
/////////////////////////////////////////////////////////////////////////////
101,13 → 48,30
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_LABEL_CopyPreset(u8 num, char *dst)
{
const int max_chars = 15;
s32 status = 0;
 
if( num < SEQ_LABEL_NumPresets() ) {
memcpy(dst, (char *)&preset_labels[num], 15);
} else {
memcpy(dst, "...............", 15);
if( num >= 1 && num <= SEQ_FILE_PRESETS_TrkLabel_NumGet() ) {
char str[max_chars+1];
 
MUTEX_SDCARD_TAKE;
status = SEQ_FILE_PRESETS_TrkLabel_Read(num, str);
MUTEX_SDCARD_GIVE;
 
if( status > 0 ) {
// fill with spaces
size_t len = strlen(str);
strncpy(dst, str, max_chars);
int i;
for(i=len; i<max_chars; ++i)
dst[i] = ' ';
}
}
 
if( status < 1 ) {
memcpy(dst, " ", max_chars);
}
 
return 0; // no error
}
 
117,7 → 81,7
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_LABEL_NumPresetsCategory(void)
{
return sizeof(preset_categories) / 6;
return SEQ_FILE_PRESETS_TrkCategory_NumGet()+1;
}
 
/////////////////////////////////////////////////////////////////////////////
126,12 → 90,30
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_LABEL_CopyPresetCategory(u8 num, char *dst)
{
if( num < SEQ_LABEL_NumPresetsCategory() ) {
memcpy(dst, (char *)&preset_categories[num], 5);
} else {
memcpy(dst, ".....", 5);
const int max_chars = 5;
s32 status = 0;
 
if( num >= 1 && num <= SEQ_FILE_PRESETS_TrkCategory_NumGet() ) {
char str[max_chars+1];
 
MUTEX_SDCARD_TAKE;
status = SEQ_FILE_PRESETS_TrkCategory_Read(num, str);
MUTEX_SDCARD_GIVE;
 
if( status > 0 ) {
// fill with spaces
size_t len = strlen(str);
strncpy(dst, str, max_chars);
int i;
for(i=len; i<max_chars; ++i)
dst[i] = ' ';
}
}
 
if( status < 1 ) {
memcpy(dst, " ", max_chars);
}
 
return 0; // no error
}
 
141,7 → 123,7
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_LABEL_NumPresetsDrum(void)
{
return sizeof(preset_drum) / 6;
return SEQ_FILE_PRESETS_TrkDrum_NumGet();
}
 
/////////////////////////////////////////////////////////////////////////////
148,13 → 130,31
// This function copies a preset drum label (5 chars) into the given array
// Could be loaded from SD-Card later
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_LABEL_CopyPresetDrum(u8 num, char *dst)
s32 SEQ_LABEL_CopyPresetDrum(u8 num, char *dst, u8 *note)
{
if( num < SEQ_LABEL_NumPresetsDrum() ) {
memcpy(dst, (char *)&preset_drum[num], 5);
} else {
memcpy(dst, ".....", 5);
const int max_chars = 5;
s32 status = 0;
 
if( num >= 0 && num < SEQ_FILE_PRESETS_TrkDrum_NumGet() ) {
char str[max_chars+1];
 
MUTEX_SDCARD_TAKE;
status = SEQ_FILE_PRESETS_TrkDrum_Read(num+1, str, note, 0);
MUTEX_SDCARD_GIVE;
 
if( status > 0 ) {
// fill with spaces
size_t len = strlen(str);
strncpy(dst, str, max_chars);
int i;
for(i=len; i<max_chars; ++i)
dst[i] = ' ';
}
}
 
if( status < 1 ) {
memcpy(dst, " ", max_chars);
}
 
return 0; // no error
}
/trunk/apps/sequencers/midibox_seq_v4/core/seq_label.h
37,7 → 37,7
extern s32 SEQ_LABEL_CopyPresetCategory(u8 num, char *dst);
 
extern s32 SEQ_LABEL_NumPresetsDrum(void);
extern s32 SEQ_LABEL_CopyPresetDrum(u8 num, char *dst);
extern s32 SEQ_LABEL_CopyPresetDrum(u8 num, char *dst, u8 *note);
 
 
 
/trunk/apps/sequencers/midibox_seq_v4/Makefile
100,6 → 100,7
core/seq_file_gc.c \
core/seq_file_t.c \
core/seq_file_bm.c \
core/seq_file_presets.c \
core/seq_file_hw.c \
core/seq_layer.c \
core/seq_random.c \