Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sample-transfer that compiles with some caveats #313

Open
wants to merge 37 commits into
base: sample-transfer
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
035e1f8
Update spi.c
prgmsoftware Mar 22, 2018
915f5df
Update module.h
prgmsoftware Mar 22, 2018
a2d991e
Update bfin.h
prgmsoftware Mar 22, 2018
3900fb5
Update bfin.c
prgmsoftware Mar 22, 2018
905daab
Update filesystem.h
prgmsoftware Mar 22, 2018
4e6f98e
Update filesystem.c
prgmsoftware Mar 22, 2018
ade093b
Update files.h
prgmsoftware Mar 22, 2018
f14ed35
Update files.c
prgmsoftware Mar 22, 2018
073c30c
Update fat_filelib.h
prgmsoftware Mar 22, 2018
3723248
Update fat_filelib.c
prgmsoftware Mar 22, 2018
2c2c35b
Update interrupts.c
prgmsoftware Mar 22, 2018
8fcef23
Update protocol.h
prgmsoftware Mar 22, 2018
8057b9d
Update app_bees.c
prgmsoftware Mar 22, 2018
0a514c7
Update init.c
prgmsoftware Mar 22, 2018
b000aee
Update mix.c
prgmsoftware Mar 22, 2018
50c6b3b
Update mix.lds
prgmsoftware Mar 22, 2018
2dbd778
Update app_bees.c
prgmsoftware Mar 24, 2018
93e3417
Update bfin.h
prgmsoftware Mar 24, 2018
482312e
Update pages.h
prgmsoftware Mar 24, 2018
a8a8f06
Update pages.h
prgmsoftware Mar 24, 2018
9726ed8
Update pages.c
prgmsoftware Mar 24, 2018
757ce60
Add files via upload
prgmsoftware Mar 24, 2018
8d9b61a
Update page_dsp.c
prgmsoftware Mar 24, 2018
e135020
Update page_ops.c
prgmsoftware Mar 24, 2018
780eead
Update files.h
prgmsoftware Mar 24, 2018
f3cd71c
Update files.c
prgmsoftware Mar 24, 2018
a6c7cef
Update params.h
prgmsoftware Mar 24, 2018
fb49150
Update params.c
prgmsoftware Mar 24, 2018
39685c1
Update mix.c
prgmsoftware Mar 24, 2018
dfea2a4
Update files.c
prgmsoftware Mar 24, 2018
c33da7a
Update files.c
prgmsoftware Mar 24, 2018
d50cf3e
Update mix.c
prgmsoftware Mar 26, 2018
c306f56
Update mix.c
prgmsoftware Mar 26, 2018
25f8a27
Update params.c
prgmsoftware Mar 26, 2018
7fc2366
Update params.h
prgmsoftware Mar 26, 2018
dc7f395
Create sample.c
prgmsoftware Mar 26, 2018
3fc4332
Add files via upload
prgmsoftware Mar 26, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/bees/src/app_bees.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ u8 app_launch(eLaunchState state) {
render_boot("waiting for DSP init...");
bfin_wait_ready();

// print_dbg("\r\n enable DSP audio...");
print_dbg("\r\n enable DSP audio...");
render_boot("enabling audio");
bfin_enable();

Expand Down
112 changes: 112 additions & 0 deletions apps/bees/src/files.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#define DSP_PATH "/mod/"
#define SCENES_PATH "/data/bees/scenes/"
#define SCALERS_PATH "/data/bees/scalers/"
#define SAMPLES_PATH "/data/bees/samples/"

// endinanness
// #define SCALER_LE 1
Expand All @@ -66,6 +67,7 @@ typedef struct _dirList {
static dirList_t dspList;
static dirList_t sceneList;
static dirList_t scalerList;
static dirList_t sampleList;

//----------------------------------
//---- static functions
Expand All @@ -77,6 +79,8 @@ static const char* list_get_name(dirList_t* list, u8 idx);
// get read file pointer if found (caller must close)
// set size by pointer
static void* list_open_file_name(dirList_t* list, const char* name, const char* mode, u32* size);
// load sample file with path
static u32 load_sample_withPath(const char *path, u32 offset);


// fake fread: no size arg, always byte
Expand Down Expand Up @@ -159,6 +163,7 @@ void files_init(void) {
list_fill(&dspList, DSP_PATH, ".ldr");
list_fill(&sceneList, SCENES_PATH, ".scn");
list_fill(&scalerList, SCALERS_PATH, ".dat");
list_fill(&sampleList, SAMPLES_PATH, ".pcm_s32be");
}


Expand Down Expand Up @@ -432,6 +437,46 @@ u8 files_load_scaler_name(const char* name, s32* dst, u32 dstSize) {
return ret;
}

////////////////////////
//// samples

// return filename for sample given index in list
const volatile char* files_get_sample_name(u8 idx) {
return list_get_name(&sampleList, idx);
}

// return count of sample files
u8 files_get_sample_count(void) {
return sampleList.num;
}

void files_load_samples(void) {
FL_DIR dirstat;
struct fs_dir_ent dirent;
sampleList.num = 0;
u32 offset = 0;

char *fpath = (char*)alloc_mem(64 * (sizeof(char*)));

// check directory for samples
strcpy(sampleList.path, SAMPLES_PATH);

if (fl_opendir(sampleList.path, &dirstat))
{
while (fl_readdir(&dirstat, &dirent) == 0)
{
if(!(dirent.is_dir))
{
strcpy(fpath, sampleList.path);
strcat(fpath, dirent.filename);
offset += load_sample_withPath(fpath, offset);
sampleList.num++;
}
}
}

free(fpath);
}

//---------------------
//------ static
Expand Down Expand Up @@ -695,3 +740,70 @@ void files_load_sample(u8 n) {
}
}

static u32 load_sample_withPath(const char *path, u32 offset) {
void *fp;

u32 fsize, foffset, fchunk, ssize;

delay_ms(10);

fp = fl_fopen(path, "r");
fsize = ((FL_FILE*)(fp))->filelength;
foffset = ((FL_FILE*)(fp))->bytenum % FAT_SECTOR_SIZE;

ssize = fsize / sizeof(s32);

// verify available SDRAM
if ((offset + ssize) < BFIN_SDRAM_MAX_FRACT32)
{
if (fp != NULL)
{
render_boot(path);

app_pause();

bfin_sample_start(offset);

do
{
if (fsize < FAT_SECTOR_SIZE)
{
fchunk = fsize;
}
else
{
fchunk = FAT_SECTOR_SIZE;
}
fsize -= fchunk;

bfin_sample_transfer(fl_return_sector(fp, foffset), fchunk);

foffset += 1;
((FL_FILE*)(fp))->bytenum += fchunk;
}
while (fsize > 0);

bfin_sample_end();

fl_fclose(fp);

app_resume();

return ssize;
}
else
{
render_boot("sample file error");
fl_fclose(fp);

return 0;
}
}
else
{
render_boot("SDRAM limit error");
fl_fclose(fp);

return 0;
}
}
6 changes: 6 additions & 0 deletions apps/bees/src/files.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "types.h"
#include "util.h"
#include "filesystem.h" //includes fat_filelib.h
EXTERN_C_BEGIN

// initialize filesystem navigation
Expand Down Expand Up @@ -63,6 +64,11 @@ extern u8 files_get_scaler_count(void);
// return 1 on success, 0 on failure
extern u8 files_load_scaler_name(const char* name, s32* dst, u32 dstSize);

//----- samples
extern const volatile char* files_get_sample_name(u8 idx);
extern u8 files_get_sample_count(void);
extern void files_load_samples(void);

//----- param descriptors
// search for named .dsc file and load into network param desc memory
extern u8 files_load_desc(const char* name);
Expand Down
6 changes: 6 additions & 0 deletions apps/bees/src/pages.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ page_t pages[NUM_PAGES] = {
.select_fn = &select_dsp, // select function
.encSens = { ENC_THRESH_LISTSCROLL, ENC_THRESH_PAGESCROLL, 0, 0, }, // encoder sens
},
{ .name = "SAMPLES",
.select_fn = &select_samples, // select function
.encSens = { ENC_THRESH_LISTSCROLL, ENC_THRESH_PAGESCROLL, 8, 8, }, // encoder sens
},
// modal:
{ .name = "GATHERED",
.select_fn = &select_gathered , // select function
Expand Down Expand Up @@ -116,6 +120,7 @@ static u8 check_edit_char(char c) {
void pages_init(void) {
init_page_ins();
init_page_dsp();
init_page_samples();
init_page_ops();
init_page_outs();
init_page_play();
Expand All @@ -131,6 +136,7 @@ void pages_init(void) {
set_page(pageIdx);

redraw_dsp();
redraw_samples();
redraw_outs();
redraw_ops();
redraw_presets();
Expand Down
6 changes: 5 additions & 1 deletion apps/bees/src/pages.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//-- define

//! number of pages (including modal pages)
#define NUM_PAGES 8
#define NUM_PAGES 9

//! enum of key handlers per menu page
typedef enum {
Expand All @@ -37,6 +37,7 @@ typedef enum {
ePageOps,
ePageScenes,
ePageDsp,
ePageSamples,
ePageGathered,
ePagePlay,
} ePage;
Expand Down Expand Up @@ -90,6 +91,7 @@ extern void init_page_presets(void);
extern void init_page_ops(void);
extern void init_page_scenes(void);
extern void init_page_dsp(void);
extern void init_page_samples(void);
extern void init_page_gathered(void);
extern void init_page_play(void);

Expand All @@ -100,6 +102,7 @@ extern void select_presets(void);
extern void select_ops(void);
extern void select_scenes(void);
extern void select_dsp(void);
extern void select_samples(void);
extern void select_gathered(void);
extern void select_play(void);

Expand All @@ -111,6 +114,7 @@ extern void redraw_presets(void);
extern void redraw_ops(void);
extern void redraw_scenes(void);
extern void redraw_dsp(void);
extern void redraw_samples(void);
extern void redraw_gathered(void);
extern void redraw_play(void);

Expand Down
2 changes: 1 addition & 1 deletion apps/bees/src/pages/page_dsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void handle_enc_2(s32 val) {
void handle_enc_1(s32 val) {
// scroll page
if(val > 0) {
set_page(ePageOps);
set_page(ePageSamples);
} else {
set_page(ePageScenes);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/bees/src/pages/page_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ void handle_enc_1(s32 val) {
if(val > 0) {
set_page(ePageIns);
} else {
set_page(ePageDsp);
set_page(ePageSamples);
}
}

Expand Down
Loading