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

Support eMMC. #18

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions src/ParserFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ bool ParserFactory::createPlaylist(const String& path) {
String file_name = file.name();
ScoreFileType type = getFileType(file_name);
if (type == kScoreFileTypeMidi || type == kScoreFileTypeTxt) {
#ifdef EMMC_USE
String kSDFullPath = "/mnt/emmc/";
#else
String kSDFullPath = "/mnt/sd0/";
#endif
// Convert file name to full path - > current path
String sd_current_path;
if (file_name.startsWith(kSDFullPath)) {
Expand Down
1 change: 1 addition & 0 deletions src/ParserFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <File.h>

#include "ScoreParser.h"
#include "YuruInstrumentConfig.h"

/**
* @brief @~japanese ScoreParser オブジェクトの Factory クラスです。
Expand Down
35 changes: 30 additions & 5 deletions src/SDSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@

#include "SDSink.h"

#ifdef EMMC_USE
#include <eMMC.h>
#define EMMC_POWER_PIN 26
#define EMMC_EN 31 // High=eMMC / Low=SD
#else
#include <SDHCI.h>
#endif

#include "WavReader.h"

Expand Down Expand Up @@ -93,6 +99,26 @@ SDSink::~SDSink() {

bool SDSink::begin() {
NullFilter::begin();

#ifdef EMMC_USE
pinMode(EMMC_EN, OUTPUT);
digitalWrite(EMMC_EN, HIGH); //eMMC Select

pinMode(EMMC_POWER_PIN, OUTPUT);
digitalWrite(EMMC_POWER_PIN, HIGH);
delay(50);
if (!eMMC.begin())
{
Serial.println("eMMC can't begin");
exit(1);
}
#else
SDClass sdcard;
if (!sdcard.begin()) {
error_printf("[%s::%s] error: cannot access sdcard\n", kClassName, __func__);
exit(1);
}
#endif
for (size_t i = 0; i < sizeof(units_) / sizeof(units_[0]); i++) {
if (units_[i].path.length() == 0) {
continue;
Expand All @@ -101,12 +127,11 @@ bool SDSink::begin() {
if (units_[i].path[0] == '/') {
file = File(units_[i].path.c_str());
} else {
SDClass sdcard;
if (!sdcard.begin()) {
error_printf("[%s::%s] error: cannot access sdcard\n", kClassName, __func__);
break;
}
#ifdef EMMC_USE
file = eMMC.open(units_[i].path.c_str());
#else
file = sdcard.open(units_[i].path.c_str());
#endif
}
if (!file) {
error_printf("[%s::%s] error: cannot open \"%s\"\n", kClassName, __func__, units_[i].path.c_str());
Expand Down
2 changes: 1 addition & 1 deletion src/SDSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <File.h>

#include "PcmRenderer.h"
#include "YuruInstrumentFilter.h"
#include "YuruInstrumentConfig.h"

/**
* @brief @~japanese ユーザーが定義した音源テーブルにしたがって、音源を再生する楽器部品です。
Expand Down
42 changes: 32 additions & 10 deletions src/SFZSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@
#include <vector>

#include <Arduino.h>

#ifdef EMMC_USE
#include <eMMC.h>
#define EMMC_POWER_PIN 26
#define EMMC_EN 31 // High=eMMC / Low=SD
#else
#include <SDHCI.h>
#endif

#include <Storage.h>

#include "path_util.h"
Expand Down Expand Up @@ -335,19 +341,35 @@ bool SFZSink::begin() {
NullFilter::begin();

debug_printf("[%s::%s] loading sfz\n", kClassName, __func__);

#ifdef EMMC_USE
pinMode(EMMC_EN, OUTPUT);
digitalWrite(EMMC_EN, HIGH); //eMMC Select

pinMode(EMMC_POWER_PIN, OUTPUT);
digitalWrite(EMMC_POWER_PIN, HIGH);
delay(50);
if (!eMMC.begin())
{
Serial.println("eMMC can't begin");
exit(1);
}
#else
SDClass sdcard;
if (!sdcard.begin()) {
error_printf("[%s::%s] error: cannot access sdcard\n", kClassName, __func__);
exit(1);
}
#endif
File file;
if (sfz_path_.startsWith("/")) {
file = File(sfz_path_.c_str());
} else {
SDClass sdcard;
if (!sdcard.begin()) {
error_printf("[%s::%s] error: cannot access sdcard\n", kClassName, __func__);
ret = false;
} else {
file = sdcard.open(sfz_path_);
sfz_path_ = file.name();
}
#ifdef EMMC_USE
file = eMMC.open(sfz_path_);
#else
file = sdcard.open(sfz_path_);
#endif
sfz_path_ = file.name();
}
if (!file) {
error_printf("[%s::%s] error: cannot open \"%s\"\n", kClassName, __func__, sfz_path_.c_str());
Expand Down
2 changes: 1 addition & 1 deletion src/SFZSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "SFZParser.h"
#include "PcmRenderer.h"
#include "YuruInstrumentFilter.h"
#include "YuruInstrumentConfig.h"

/**
* @brief @~japanese 音源定義ファイル(SFZファイル)にしたがって、音源を再生する楽器部品です。
Expand Down
2 changes: 2 additions & 0 deletions src/YuruInstrumentConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include "YuruInstrumentFilter.h"

#define EMMC_USE

/**
* @brief @~japanese Filter のパラメータ設定を行うコンフィグファイルを実現するクラスです。
*/
Expand Down
12 changes: 8 additions & 4 deletions src/YuruInstrumentConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,17 @@ struct CommandSpec {
};

static void PrintLsItem(File &file) {
const char sdroot[] = "/mnt/sd0/";
const size_t sdroot_length = strlen(sdroot);
#ifdef EMMC_USE
const char root[] = "/mnt/emmc/";
#else
const char root[] = "/mnt/sd0/";
#endif
const size_t root_length = strlen(root);
if (file) {
// drop prefix if starts with "/mnt/sd0/"
const char *path = file.name();
if (strncmp(path, sdroot, sdroot_length) == 0) {
path = path + sdroot_length;
if (strncmp(path, root, root_length) == 0) {
path = path + root_length;
}
if (file.isDirectory()) {
printf("%s/\n", path);
Expand Down