Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
bostick committed Dec 18, 2024
1 parent d78b61a commit 3be81bf
Show file tree
Hide file tree
Showing 21 changed files with 193 additions and 192 deletions.
6 changes: 2 additions & 4 deletions exe/midi-info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@ int main(int argc, const char *argv[]) {

midi_file m;

Status ret = parseMidiFile(inputFile.c_str(), m);

if (ret != OK) {
return ret;
if (parseMidiFile(inputFile.c_str(), m) != OK) {
return ERR;
}

auto info = midiFileInfo(m);
Expand Down
18 changes: 6 additions & 12 deletions exe/tbt-converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,26 +158,20 @@ int main(int argc, const char *argv[]) {

tbt_file t;

Status ret = parseTbtFile(inputFile.c_str(), t);

if (ret != OK) {
return ret;
if (parseTbtFile(inputFile.c_str(), t) != OK) {
return ERR;
}

LOGI("exporting...");

midi_file m;

ret = convertToMidi(t, opts, m);

if (ret != OK) {
return ret;
if (convertToMidi(t, opts, m) != OK) {
return ERR;
}

ret = exportMidiFile(m, outputFile.c_str());

if (ret != OK) {
return ret;
if (exportMidiFile(m, outputFile.c_str()) != OK) {
return ERR;
}

LOGI("finished!");
Expand Down
6 changes: 2 additions & 4 deletions exe/tbt-info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,8 @@ int main(int argc, const char *argv[]) {

tbt_file t;

Status ret = parseTbtFile(inputFile.c_str(), t);

if (ret != OK) {
return ret;
if (parseTbtFile(inputFile.c_str(), t) != OK) {
return ERR;
}

#ifndef NDEBUG
Expand Down
12 changes: 4 additions & 8 deletions exe/tbt-printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,8 @@ int main(int argc, const char *argv[]) {

LOGI("parsing...");

Status ret = parseTbtFile(inputFile.c_str(), t);

if (ret != OK) {
return ret;
if (parseTbtFile(inputFile.c_str(), t) != OK) {
return ERR;
}

LOGI("printing...");
Expand All @@ -102,10 +100,8 @@ int main(int argc, const char *argv[]) {

auto buf = std::vector<uint8_t>(tab.begin(), tab.end());

ret = saveFile(outputFile.c_str(), buf);

if (ret != OK) {
return ret;
if (saveFile(outputFile.c_str(), buf) != OK) {
return ERR;
}

LOGI("finished!");
Expand Down
16 changes: 16 additions & 0 deletions include/tbt-parser/rational.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,19 @@ class rational {
rational floor() const;
rational round() const;
};
















5 changes: 5 additions & 0 deletions include/tbt-parser/tbt-parser-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,8 @@ uint8_t width(int a);








5 changes: 5 additions & 0 deletions include/tbt-parser/tbt.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,8 @@ const std::array<int8_t, 6> OPEN_STRING_TO_MIDI_NOTE_LE6A = {








18 changes: 9 additions & 9 deletions lib/alternate-time-regions.inl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


#ifdef TAG
#error alternate-time-regions.inl is being included where TAG is already defined
#endif // TAG

#define TAG "alternate-time-regions"


Expand All @@ -43,10 +47,8 @@ parseAlternateTimeRegionsMapList(

std::vector<uint8_t> deltaList;

Status ret = parseDeltaListChunk(it, end, deltaList);

if (ret != OK) {
return ret;
if (parseDeltaListChunk(it, end, deltaList) != OK) {
return ERR;
}

alternateTimeRegionsDeltaListAcc.insert(
Expand All @@ -55,10 +57,8 @@ parseAlternateTimeRegionsMapList(
deltaList.cend()
);

ret = computeDeltaListCount(deltaList, &dsqCount);

if (ret != OK) {
return ret;
if (computeDeltaListCount(deltaList, &dsqCount) != OK) {
return ERR;
}

CHECK(dsqCount <= 2 * trackSpaceCount, "unhandled");
Expand All @@ -78,7 +78,7 @@ parseAlternateTimeRegionsMapList(
);

if (ret != OK) {
return ret;
return ERR;
}

rational alternateTimeRegionsCorrection = 0;
Expand Down
28 changes: 15 additions & 13 deletions lib/bar-lines.inl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


#ifdef TAG
#error bar-lines.inl is being included where TAG is already defined
#endif // TAG

#define TAG "bar-lines"


Expand Down Expand Up @@ -44,10 +48,8 @@ parseBarLinesMap(

std::vector<std::array<uint8_t, 6> > parts;

Status ret = partitionInto<6>(data, parts);

if (ret != OK) {
return ret;
if (partitionInto<6>(data, parts) != OK) {
return ERR;
}

out.body.barLinesSpaceCount = 0;
Expand Down Expand Up @@ -84,18 +86,14 @@ parseBarLinesMap(

std::vector<uint8_t> deltaList;

Status ret = parseDeltaListChunk(it, end, deltaList);

if (ret != OK) {
return ret;
if (parseDeltaListChunk(it, end, deltaList) != OK) {
return ERR;
}

barLinesDeltaListAcc.insert(barLinesDeltaListAcc.end(), deltaList.cbegin(), deltaList.cend());

ret = computeDeltaListCount(deltaList, &sqCount);

if (ret != OK) {
return ret;
if (computeDeltaListCount(deltaList, &sqCount) != OK) {
return ERR;
}

CHECK(sqCount <= barLinesSpaceCount, "unhandled");
Expand All @@ -105,7 +103,11 @@ parseBarLinesMap(
}
}

Status ret = expandDeltaList<1>(barLinesDeltaListAcc, barLinesSpaceCount, 0, out.body.barLinesMap);
Status ret = expandDeltaList<1>(
barLinesDeltaListAcc,
barLinesSpaceCount,
0,
out.body.barLinesMap);

if (ret != OK) {
return ret;
Expand Down
26 changes: 13 additions & 13 deletions lib/body.inl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


#ifdef TAG
#error body.inl is being included where TAG is already defined
#endif // TAG

#define TAG "body"


Expand All @@ -36,10 +40,8 @@ parseBody(
// parse bar lines
//

Status ret = parseBarLinesMap<VERSION, tbt_file_t>(it, end, out);

if (ret != OK) {
return ret;
if (parseBarLinesMap<VERSION, tbt_file_t>(it, end, out) != OK) {
return ERR;
}


Expand All @@ -53,6 +55,8 @@ parseBody(
// parse notes
//

Status ret;

if constexpr (0x6b <= VERSION) {

ret = parseNotesMapList<VERSION, tbt_file_t, 8>(it, end, out);
Expand All @@ -63,7 +67,7 @@ parseBody(
}

if (ret != OK) {
return ret;
return ERR;
}

//
Expand All @@ -72,10 +76,8 @@ parseBody(

if constexpr (HASALTERNATETIMEREGIONS) {

ret = parseAlternateTimeRegionsMapList<VERSION, tbt_file_t>(it, end, out);

if (ret != OK) {
return ret;
if (parseAlternateTimeRegionsMapList<VERSION, tbt_file_t>(it, end, out) != OK) {
return ERR;
}
}

Expand All @@ -85,10 +87,8 @@ parseBody(

if constexpr (0x71 <= VERSION) {

ret = parseTrackEffectChangesMapList<VERSION, tbt_file_t>(it, end, out);

if (ret != OK) {
return ret;
if (parseTrackEffectChangesMapList<VERSION, tbt_file_t>(it, end, out) != OK) {
return ERR;
}
}

Expand Down
10 changes: 6 additions & 4 deletions lib/expanddeltalist.inl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


#ifdef TAG
#error expandDeltaList.inl is being included where TAG is already defined
#endif // TAG

#define TAG "expandDeltaList"


Expand All @@ -35,10 +39,8 @@ expandDeltaList(

std::vector<std::array<uint8_t, 2> > parts;

Status ret = partitionInto<2>(deltaList, parts);

if (ret != OK) {
return ret;
if (partitionInto<2>(deltaList, parts) != OK) {
return ERR;
}

std::vector<std::vector<std::array<uint8_t, 2> > > split;
Expand Down
6 changes: 5 additions & 1 deletion lib/last-found.inl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


#define TAG "last_found"
#ifdef TAG
#error last-found.inl is being included where TAG is already defined
#endif // TAG

#define TAG "last-found"


//
Expand Down
4 changes: 4 additions & 0 deletions lib/metadata.inl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


#ifdef TAG
#error metadata.inl is being included where TAG is already defined
#endif // TAG

#define TAG "metadata"


Expand Down
Loading

0 comments on commit 3be81bf

Please sign in to comment.