Comments (4)
Towards your first question, the general strategy would be:
- get the sample rate
- calculate your delay length in terms of samples and numbers of buffer periods
- read the midi events and store them together with a timestamp (e.g. samples since startup)
- in each period, check if the delay number of buffer periods and samples has passed, comparing the stored timestamps to the current number of periods/samples since startup, and, if yes
- add the stored midi events to the output buffer
from protoplug.
I think I already got the midimsg delay working (I looked at the midiChordify example):
require "include/protoplug"
local mididelay
local delayBuf = {}
local playing = false
function plugin.processBlock(samples, smax, midiBuf)
blockEvents = {}
-- analyse midi buffer and push them to midiDelaybuffer
for ev in midiBuf:eachEvent() do
ev.time = ev.time + mididelay
table.insert( delayBuf, ev )
end
-- fill midi buffer with delayed notes (if any)
midiBuf:clear()
sendDelayBuf(midiBuf)
sendMMC()
end
function sendDelayBuf(midiBuf)
if #delayBuf>0 then
for _,e in ipairs(delayBuf) do
if e.time < smax then
midiBuf:addEvent(e)
table.remove( delayBuf, _ )
print "midi msg!"
else
e.time = e.time - smax
end
end
end
end
function sendMMC()
if not playing and plugin.PositionInfo.isPlaying
-- send start to midi out ( 0xF0 0x7F 0x7F 0x06 0x02 )
end
if playing and not plugin.PositionInfo.isPlaying
-- send stop to midi out ( 0xF0 0x7F 0x7F 0x06 0x01 )
end
end
params = plugin.manageParams {
{
name = "Mididelay";
type = "int";
max = 50000;
changed = function(val) mididelay = val end;
}
}
Now I only need to send out the midi bytes by creating some custom midi events.
WDYT?
ps. actually its not important to deal with real milliseconds since the only purpose of the slider is to do a manual correction by ear. (compensate hardware/software midi delay)
from protoplug.
For receiving start and stop events from the host, you can use plugin.getCurrentPosition().isPlaying. Here's an example:
require "include/protoplug"
local oldPlaying = false
function plugin.processBlock(samples, smax, midiBuf)
local info = plugin.getCurrentPosition()
if info and info.isPlaying ~= oldPlaying then
print (info.isPlaying and "Host started playing!" or "Host stopped!")
oldPlaying = info.isPlaying
end
end
For sending custom MIDI messages, the API docs are pretty explicit, there's even an example!:
http://www.osar.fr/protoplug/api/modules/midi.html#midi.Event:Event
from protoplug.
indeed nothing wrong with those docs!
thnx
from protoplug.
Related Issues (20)
- vst builds on linux fail to load
- Feature Request: Please add feature to report latency to host
- Not working on Catalina HOT 2
- FYI : New Tutorial Video HOT 6
- EBM generator [broken] HOT 2
- Understanding midi.noteToFreq HOT 2
- How to extend the midi API HOT 26
- problems in the timing API HOT 1
- midi API needs support for ProgramChange, ChannelPressure and PolyPressure events HOT 1
- error calling plugin_processBlock() : not enough memory HOT 4
- can compile scripts in Logic Pro, but nothing happens HOT 5
- Any chance to see this ported to ARM macs? HOT 1
- Is it possible to call a compiled C DLL from protoplug?
- midi event constructor seems to be busted
- FYI : WaveFolding Oscillator Example
- FYI : Phase Modulation Example
- Mac 10.14.6 Cannot Load libluajit-5.1.so HOT 1
- LV2 version? HOT 1
- Protoplug 1.4.0 build no longer running on recent Ubuntus (and cannot rebuild)
- Add support for aftertouch and polyphonic aftertouch events HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protoplug.