Author Topic: Listing things  (Read 4493 times)

I'm working on MIDI Events for blockland, I wanted an easier way to have things happen without going back and forth
to see if I timed it right. I'm hoping Torque and Blockland can use MIDI, if not, then I'm screwed. I can't seem to list MIDI Files from a folder or zip file. Help me out here, I have no experience with torque, I'm only learning from addons, but I can make like sounds, prints, easy stuff. Well easy for me

This is how I left it as I posted this.
Code: [Select]
function MIDI_SongList($MIDI)
 {
   //
   %pattern = "Add-Ons/MIDI_MIDI_Files/*.mid";
  
   $MIDI::numMIDIs = 0;
  
   %file = findFirstFile(%pattern);
   while(%file !$= "")
   {
      $MIDI::Song[$MIDI::numMIDIs] = %file;
      $MIDI::numMIDIs++;

      %file = findNextFile(%pattern);
   }
 }

RegisterOutputEvent(fxDTSBrick,"Set_MIDI_pref","int 1 16 1\tint 0 127 60",1);
RegisterOutputEvent(fxDTSBrick,"Play_MIDI_file","list $MIDI" TAB "bool");
//The MIDI Preferences are Channel, then note. The Play MIDI file bool is for
//whether or not the song will be played or stopped.

function MIDI_note_is_on()
{
}
RegisterInputEvent(fxDTSBrick,"MIDI_note_is_on","Self fxDTSBrick");

function MIDI_note_is_off()
{
}
RegisterInputEvent(fxDTSBrick,"MIDI_note_is_off","Self fxDTSBrick");

MIDI note on and off explain them self's, basically everything is explained, I just get can't get the list to work.
« Last Edit: May 04, 2014, 09:03:27 PM by Blockteen »

blockland can't use MIDIs?

Unfortunately Torque does not support MIDI files. I'm not quite sure why you thought it would since it's a game engine not a DAW, but whatever. Sorry.

Unfortunately Torque does not support MIDI files. I'm not quite sure why you thought it would since it's a game engine not a DAW, but whatever. Sorry.
Other programs besides DAWs support MIDI, though.

Are you guys sure there's no way to write an interpreter for .mid files?

Absolutely certain. Sorry bud.

What did you want to do with the midi files? Maybe there is another way.

Port has done something like this before?

Other programs besides DAWs support MIDI, though.

Are you guys sure there's no way to write an interpreter for .mid files?

My statement was akin to saying "I'm not quite sure why you thought a television would run on gasoline since it's not a car, but whatever." Sure, things other than cars run on gas, but the gist of my statement is understood.

You can't really do anything with binary files in torque.  You need to be able to parse regular text in the file.

Also, just a quick thing - function MIDI_SongList($MIDI) should be function MIDI_SongList(%midi). You can't put global variables ($) as arguments for a function.

Port has done something like this before?
Can you link, if one

What did you want to do with the midi files? Maybe there is another way.
I want an easier way to event things in Blockland

Also, just a quick thing - function MIDI_SongList($MIDI) should be function MIDI_SongList(%midi). You can't put global variables ($) as arguments for a function.
Noted, now I get this error in console.
Code: [Select]
WARNING: list has odd number of arguments on class:fxDTSBrick, event:Play_MIDI_file
BackTrace: ->ServerSettingsGui::clickLaunchGame->createServer->onServerCreated->loadAddOns->registerOutputEvent->verifyOutputParameterList

And then there is the current updated add-on code.
Code: [Select]
function MIDI_SongList(%midi)
 {
   //
   %pattern = "Add-Ons/MIDI_MIDI_Files/*.mid";
   
   $MIDI::numMIDIs = 0;
   
   %file = findFirstFile(%pattern);
   while(%file !$= "")
   {
      $MIDI::Song[$MIDI::numMIDIs] = %file;
      $MIDI::numMIDIs++;

      %file = findNextFile(%pattern);
   }
 }

RegisterOutputEvent(fxDTSBrick,"Set_MIDI_pref","int 1 16 1\tint 0 127 60",1);
RegisterOutputEvent(fxDTSBrick,"Play_MIDI_file","list $MIDI" TAB "bool");
//The MIDI Preferences are Channel, then note. The Play MIDI file bool is for
//whether or not the song will be played or stopped.

function MIDI_note_is_on()
{
}
RegisterInputEvent(fxDTSBrick,"MIDI_note_is_on","Self fxDTSBrick");

function MIDI_note_is_off()
{
}
RegisterInputEvent(fxDTSBrick,"MIDI_note_is_off","Self fxDTSBrick");

Also, just a quick thing - function MIDI_SongList($MIDI) should be function MIDI_SongList(%midi). You can't put global variables ($) as arguments for a function.


Yes you can actually, but for OP's case, he should use a local variable.

Port has done something like this before?

Port made an ABC parser, not a MIDI one.
« Last Edit: May 05, 2014, 09:20:24 PM by Wrapperup »

Also, just a quick thing - function MIDI_SongList($MIDI) should be function MIDI_SongList(%midi). You can't put global variables ($) as arguments for a function.
Yes you can. It's actually quite useful if you want to set multiple global variables at once.

function setGlobalVariables($FirstThing, $SecondThing, $ThirdThing) {}

Will set all 3 global variables with those names to whatever you call the function with.

I want an easier way to event things in Blockland
Event what things? In case you didn't get it, you cannot read or use midi files.

Event what things? In case you didn't get it, you cannot read or use midi files.
I want to re-create Walt Disney's Carousel of Progress in Blockland from Walt Disney World