Coder Social home page Coder Social logo

elihugarret / lovemidi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sience/lovemidi

1.0 2.0 0.0 1.63 MB

lovemidi is a nativ crossplatform MIDI I/O library for LUA | LÖVE | Love2D

Makefile 1.07% CSS 0.31% C 79.23% Lua 13.10% C++ 5.91% Shell 0.37%

lovemidi's Introduction

lovemidi

lovemidi is a project to give LÖVE a midi i/o interface. lovemidi is based on luamidi and the newest rtmidi library.

LÖVE/Lua compatibility

  • The current version is compatible with LÖVE 0.9.1, LÖVE 0.8.0, LÖVE 0.72 and Lua 5.1.x
  • For x86 choose luamidi.dll
  • For win64 choose luamidi.dll_64 and rename to luamidi.dll

The current binary is compiled with VS2012 (as LÖVE 0.9.1). Other LÖVE/Lua could bring different Visual Studios runtimes. If the library does not work, you have to install the Visual Studio 2012 Runtime.

Example

Output (send Midi Data to Output-Port 0)

-- initialize the library
local midi = require "luamidi"

-- count output-ports
print("Midi Output Ports: ", midi.getoutportcount() )

-- play a note on output-port 0 on channel 1
-- port, note, [vel], [channel]
midi.noteOn(0, 60, 50, 1)

-- deinitialize library
midi.gc()

Input (receive Midi Data from Input-Port 0)

-- initialize the library
local midi = require "luamidi"

-- look for available input ports
print("Midi Input Ports: ", midi.getinportcount())

if midi.getinportcount() > 0 then
	table.foreach(midi.enumerateinports(), print)
	print( 'Receiving on device: ', luamidi.getInPortName(0))
	print()

	local a, b, c, d = nil
	while true do
		-- recive midi command from input-port 0
		-- command, note, velocity, delta-time-to-last-event (just ignore)
		a,b,c,d = midi.getMessage(0)
		
		if a ~= nil then
			-- look for an NoteON command
			if a == 144 then
				print('Note turned ON:	', a, b, c, d)
			-- look for an NoteOFF command
			elseif a == 128 then
				print('Note turned OFF:', a, b, c, d)
			end
		end
	end
end

-- deinitialize library
midi.gc()

For more advanced examples please look into the tests/ folder.

Installation

Just add the right luamidi.dll (for LÖVE x86) or luamidi.dll_64 (rename to luamidi.dll) (for LÖVE win64) to your project.

TODO

Still todo is to update the current makefile to create binaries for linux and macosx.

References

  • lovemidi uses luamidi (older rtmidi, less compatibility)
  • luamidi used rtmidi for cross platform midi compatibilty Linux/MacOSX/Windows

License

Copyright (c)'2014 Florian Fischer

lovemidi uses the same license as rtMidi and luamidi (MIT)

LEGAL AND ETHICAL:

The RtMidi license is similar to the the MIT License, with the added "feature" that modifications be sent to the developer.

RtMidi: realtime MIDI i/o C++ classes
Copyright (c) 2003-2014 Gary P. Scavone

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

Any person wishing to distribute modifications to the Software is
asked to send the modifications to the original developer so that
they can be incorporated into the canonical version.  This is,
however, not a binding provision of this license.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

lovemidi's People

Contributors

sience avatar

Stargazers

Elihu Garrett avatar

Watchers

James Cloos avatar Elihu Garrett avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.