MIDI Note to Filename

Free, open source visual programming system for creative coding
Post Reply
andykoa
Posts: 3
Joined: Mon Jun 04, 2018 10:14 pm

MIDI Note to Filename

Post by andykoa » Mon Jun 04, 2018 10:21 pm

Hi there,

I just discovered Fugio and it looks like this can solve my need of a MIDI VIDEO PLAYER.
But I really can't find Examples or a Documentation hat helps me.

Can someone give me an example how to convert the MIDI values NOTE and CHANNEL to a filename for the Mediaplayer

for example:

MIDI Channel 1 and MIDI Note 77 returns filename "1/77.mp4" (File "77.mp4" in Folder "1")
MIDI Channel 2 and MIDI Note 66 returns filename "2/66.mp4"
...

Any help would be very appreciated.

Cheers
Andy

Demuth
Posts: 1
Joined: Mon May 28, 2018 10:48 am

Re: MIDI Note to Filename

Post by Demuth » Tue Jun 05, 2018 5:27 pm

Hi Andy, I just discovered Fugio as well. Yeah, I wish there were more resources about it. Hopefully, that'll come in time.

andykoa
Posts: 3
Joined: Mon Jun 04, 2018 10:14 pm

Re: MIDI Note to Filename

Post by andykoa » Fri Jun 08, 2018 9:59 am

Seems this could be done with LUA.
Any idea?

andykoa
Posts: 3
Joined: Mon Jun 04, 2018 10:14 pm

Re: MIDI Note to Filename

Post by andykoa » Fri Jun 08, 2018 11:24 am

Could this work?

Code: Select all


fugio = require "fugio"

PinInput1 = fugio.input( "Input1" )
PinInput2 = fugio.input( "Input2" )
PinOutput = fugio.output( "Output" )

local filepath 	= "C:/videos/"
local suffix 	= ".mp4"


functions main()

	-- putting it all together

	local midichannel 	= PinOutput1:get()
	local midinote	 	= PinOutput2:get()
	local filename 		= filepath .. midichannel .. "/" .. midinote .. suffix
	
	-- log output
	
	fugio.log( midichannel )
	fugio.log( midinote )
	fugio.log( filename )
	
	-- check if file exists
	
	local f=io.open(filename,"r")
	
	if f~=nil then
		-- file does not exist
		fugio.log( "File does not exist" )
	
	else
	
		-- file exists
		fugio.log( "File does exist" )
		PinOutput:set( filename )
		
	end
	
	io.close(f)

end


Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest