Skip to content

Commit

Permalink
[audio_basics] Add midi message types
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed Oct 17, 2023
1 parent 51ff165 commit 39130a2
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 1 deletion.
4 changes: 4 additions & 0 deletions module/lua_juce/lua_juce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ auto allModules(sol::state& lua) -> void

// juce_audio_basics
juce_AudioPlayHead(table);
juce_MidiFile(table);
juce_MidiMessage(table);
juce_MidiMessageSequence(table);
juce_MidiRPNDetector(table);
juce_MidiRPNMessage(table);

// juce_data_structures
juce_UndoableAction(table);
Expand Down
4 changes: 4 additions & 0 deletions module/lua_juce_audio_basics/lua_juce_audio_basics.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#include <lua_juce_audio_basics/lua_juce_audio_basics.hpp>

#include "audio_play_head/AudioPlayHead.cpp" // NOLINT
#include "midi/MidiFile.cpp" // NOLINT
#include "midi/MidiMessage.cpp" // NOLINT
#include "midi/MidiMessageSequence.cpp" // NOLINT
#include "midi/MidiRPNDetector.cpp" // NOLINT
#include "midi/MidiRPNMessage.cpp" // NOLINT
4 changes: 4 additions & 0 deletions module/lua_juce_audio_basics/lua_juce_audio_basics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ END_JUCE_MODULE_DECLARATION

namespace lua_juce {
auto juce_AudioPlayHead(sol::table& state) -> void;
auto juce_MidiFile(sol::table& state) -> void;
auto juce_MidiMessage(sol::table& state) -> void;
auto juce_MidiRPNDetector(sol::table& state) -> void;
auto juce_MidiRPNMessage(sol::table& state) -> void;
auto juce_MidiMessageSequence(sol::table& state) -> void;
} // namespace lua_juce
23 changes: 23 additions & 0 deletions module/lua_juce_audio_basics/midi/MidiFile.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace lua_juce {

auto juce_MidiFile(sol::table& state) -> void
{
auto midiFile = state.new_usertype<juce::MidiFile>("MidiFile", sol::constructors<juce::MidiFile()>());

midiFile["getNumTracks"] = LUA_JUCE_C_CALL(&juce::MidiFile::getNumTracks);
midiFile["getTrack"] = LUA_JUCE_C_CALL(&juce::MidiFile::getTrack);
midiFile["addTrack"] = LUA_JUCE_C_CALL(&juce::MidiFile::addTrack);
midiFile["clear"] = LUA_JUCE_C_CALL(&juce::MidiFile::clear);
midiFile["getTimeFormat"] = LUA_JUCE_C_CALL(&juce::MidiFile::getTimeFormat);
midiFile["setTicksPerQuarterNote"] = LUA_JUCE_C_CALL(&juce::MidiFile::setTicksPerQuarterNote);
midiFile["setSmpteTimeFormat"] = LUA_JUCE_C_CALL(&juce::MidiFile::setSmpteTimeFormat);
midiFile["findAllTempoEvents"] = LUA_JUCE_C_CALL(&juce::MidiFile::findAllTempoEvents);
midiFile["findAllTimeSigEvents"] = LUA_JUCE_C_CALL(&juce::MidiFile::findAllTimeSigEvents);
midiFile["findAllKeySigEvents"] = LUA_JUCE_C_CALL(&juce::MidiFile::findAllKeySigEvents);
midiFile["getLastTimestamp"] = LUA_JUCE_C_CALL(&juce::MidiFile::getLastTimestamp);
midiFile["readFrom"] = LUA_JUCE_C_CALL(&juce::MidiFile::readFrom);
midiFile["writeTo"] = LUA_JUCE_C_CALL(&juce::MidiFile::writeTo);
midiFile["convertTimestampTicksToSeconds"] = LUA_JUCE_C_CALL(&juce::MidiFile::convertTimestampTicksToSeconds);
}

} // namespace lua_juce
38 changes: 38 additions & 0 deletions module/lua_juce_audio_basics/midi/MidiMessageSequence.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace lua_juce {

auto juce_MidiMessageSequence(sol::table& state) -> void
{
auto midiSequence = state.new_usertype<juce::MidiMessageSequence>("MidiMessageSequence", sol::constructors<juce::MidiMessageSequence()>());

midiSequence["clear"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::clear);
midiSequence["getNumEvents"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::getNumEvents);
midiSequence["getEventPointer"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::getEventPointer);
midiSequence["getTimeOfMatchingKeyUp"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::getTimeOfMatchingKeyUp);
midiSequence["getIndexOfMatchingKeyUp"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::getIndexOfMatchingKeyUp);
midiSequence["getIndexOf"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::getIndexOf);
midiSequence["getNextIndexAtTime"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::getNextIndexAtTime);
midiSequence["getStartTime"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::getStartTime);
midiSequence["getEndTime"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::getEndTime);
midiSequence["getEventTime"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::getEventTime);
midiSequence["deleteEvent"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::deleteEvent);
midiSequence["updateMatchedPairs"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::updateMatchedPairs);
midiSequence["sort"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::sort);
midiSequence["extractMidiChannelMessages"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::extractMidiChannelMessages);
midiSequence["extractSysExMessages"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::extractSysExMessages);
midiSequence["deleteMidiChannelMessages"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::deleteMidiChannelMessages);
midiSequence["deleteSysExMessages"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::deleteSysExMessages);
midiSequence["addTimeToMessages"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::addTimeToMessages);
midiSequence["createControllerUpdatesForTime"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::createControllerUpdatesForTime);
midiSequence["swapWith"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::swapWith);

// midiSequence["begin"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::begin);
// midiSequence["begin"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::begin);
// midiSequence["end"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::end);
// midiSequence["end"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::end);
// midiSequence["addEvent"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::addEvent);
// midiSequence["addEvent"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::addEvent);
// midiSequence["addSequence"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::addSequence);
// midiSequence["addSequence"] = LUA_JUCE_C_CALL(&juce::MidiMessageSequence::addSequence);
}

} // namespace lua_juce
10 changes: 10 additions & 0 deletions module/lua_juce_audio_basics/midi/MidiRPNDetector.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace lua_juce {

auto juce_MidiRPNDetector(sol::table& state) -> void
{
auto detector = state.new_usertype<juce::MidiRPNDetector>("MidiRPNDetector", sol::default_constructor);
detector["reset"] = LUA_JUCE_C_CALL(&juce::MidiRPNDetector::reset);
detector["tryParse"] = LUA_JUCE_C_CALL(&juce::MidiRPNDetector::tryParse);
}

} // namespace lua_juce
14 changes: 14 additions & 0 deletions module/lua_juce_audio_basics/midi/MidiRPNMessage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace lua_juce {

auto juce_MidiRPNMessage(sol::table& state) -> void
{
auto midiSequence = state.new_usertype<juce::MidiRPNMessage>("MidiRPNMessage", sol::default_constructor);

midiSequence["channel"] = LUA_JUCE_C_CALL(&juce::MidiRPNMessage::channel);
midiSequence["parameterNumber"] = LUA_JUCE_C_CALL(&juce::MidiRPNMessage::parameterNumber);
midiSequence["value"] = LUA_JUCE_C_CALL(&juce::MidiRPNMessage::value);
midiSequence["isNRPN"] = LUA_JUCE_C_CALL(&juce::MidiRPNMessage::isNRPN);
midiSequence["is14BitValue"] = LUA_JUCE_C_CALL(&juce::MidiRPNMessage::is14BitValue);
}

} // namespace lua_juce
65 changes: 65 additions & 0 deletions tool/jml-documentation/Documentation.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# JML Documentation

- [juce_audio_basics](#juce_audio_basics)
- [MidiFile](#MidiFile)
- [MidiMessage](#MidiMessage)
- [MidiMessageSequence](#MidiMessageSequence)
- [MidiRPNDetector](#MidiRPNDetector)
- [MidiRPNMessage](#MidiRPNMessage)
- [juce_core](#juce_core)
- [BigInteger](#BigInteger)
- [File](#File)
Expand Down Expand Up @@ -41,6 +45,25 @@

## juce_audio_basics

## MidiFile

```lua
juce.MidiFile.addTrack(...)
juce.MidiFile.clear(...)
juce.MidiFile.convertTimestampTicksToSeconds(...)
juce.MidiFile.findAllKeySigEvents(...)
juce.MidiFile.findAllTempoEvents(...)
juce.MidiFile.findAllTimeSigEvents(...)
juce.MidiFile.getLastTimestamp(...)
juce.MidiFile.getNumTracks(...)
juce.MidiFile.getTimeFormat(...)
juce.MidiFile.getTrack(...)
juce.MidiFile.new(...)
juce.MidiFile.readFrom(...)
juce.MidiFile.setSmpteTimeFormat(...)
juce.MidiFile.setTicksPerQuarterNote(...)
juce.MidiFile.writeTo(...)
```
## MidiMessage

```lua
Expand Down Expand Up @@ -143,6 +166,48 @@ juce.MidiMessage.textMetaEvent(...)
juce.MidiMessage.timeSignatureMetaEvent(...)
juce.MidiMessage.withTimeStamp(...)
```
## MidiMessageSequence

```lua
juce.MidiMessageSequence.addTimeToMessages(...)
juce.MidiMessageSequence.clear(...)
juce.MidiMessageSequence.createControllerUpdatesForTime(...)
juce.MidiMessageSequence.deleteEvent(...)
juce.MidiMessageSequence.deleteMidiChannelMessages(...)
juce.MidiMessageSequence.deleteSysExMessages(...)
juce.MidiMessageSequence.extractMidiChannelMessages(...)
juce.MidiMessageSequence.extractSysExMessages(...)
juce.MidiMessageSequence.getEndTime(...)
juce.MidiMessageSequence.getEventPointer(...)
juce.MidiMessageSequence.getEventTime(...)
juce.MidiMessageSequence.getIndexOf(...)
juce.MidiMessageSequence.getIndexOfMatchingKeyUp(...)
juce.MidiMessageSequence.getNextIndexAtTime(...)
juce.MidiMessageSequence.getNumEvents(...)
juce.MidiMessageSequence.getStartTime(...)
juce.MidiMessageSequence.getTimeOfMatchingKeyUp(...)
juce.MidiMessageSequence.new(...)
juce.MidiMessageSequence.sort(...)
juce.MidiMessageSequence.swapWith(...)
juce.MidiMessageSequence.updateMatchedPairs(...)
```
## MidiRPNDetector

```lua
juce.MidiRPNDetector.new(...)
juce.MidiRPNDetector.reset(...)
juce.MidiRPNDetector.tryParse(...)
```
## MidiRPNMessage

```lua
juce.MidiRPNMessage.channel(...)
juce.MidiRPNMessage.is14BitValue(...)
juce.MidiRPNMessage.isNRPN(...)
juce.MidiRPNMessage.new(...)
juce.MidiRPNMessage.parameterNumber(...)
juce.MidiRPNMessage.value(...)
```
## juce_core

## BigInteger
Expand Down
8 changes: 7 additions & 1 deletion tool/jml-documentation/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@ writeTypesDocsAsMarkdown(file, "snippets", {
juce.RelativeTime.seconds(1.0),
juce.Time.new(),
},
juce_audio_basics = {juce.MidiMessage.new()},
juce_audio_basics = {
juce.MidiFile.new(),
juce.MidiMessage.new(),
juce.MidiMessageSequence.new(),
juce.MidiRPNDetector.new(),
juce.MidiRPNMessage.new(),
},
juce_data_structures = {juce.UndoManager.new(0, 0), juce.ValueTree.new()},
juce_graphics = {
juce.AffineTransform.new(),
Expand Down

0 comments on commit 39130a2

Please sign in to comment.