Advertisement
Guest User

Untitled

a guest
Nov 9th, 2015
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 4.52 KB | None | 0 0
  1. {$Hints OFF}{$Warnings OFF}
  2. {$ifndef main_include}
  3. library FruityPlug;
  4. uses
  5.     windows,uPlugin;
  6.  
  7. exports
  8.        CreatePlugInstance;
  9.  
  10. begin
  11.       allocconsole
  12. end.
  13. {$else}
  14.  
  15.  
  16. (*
  17.  
  18.       TNoteParams=Packed Record
  19.           Position,Length
  20.                       :Integer;        // in PPQ
  21.           // levels
  22.           Pan         :Integer;        // default=0
  23.           Vol         :Single;         // default=100/128
  24.           Note        :SmallInt;       // default=60
  25.           Color       :SmallInt;       // 0..15 (=MIDI channel)
  26.           Pitch       :Integer;        // default=0
  27.           FCut,FRes   :Single;         // default=0
  28.         End;
  29.       TNotesParams=Record
  30.           Target      :Integer;        // 0=step seq (not supported yet), 1=piano roll
  31.           Flags       :Integer;        // see NPF_EmptyFirst
  32.           PatNum      :Integer;        // -1 for current
  33.           ChanNum     :Integer;        // -1 for plugin's channel, or selected channel if plugin is an effect
  34.           Count       :Integer;        // the # of notes in the structure
  35.           NoteParams:Array[0..0] of TNoteParams;  // array of notes
  36.         End;
  37.       PNotesParams=^TNotesParams;
  38. *)
  39.  
  40.  
  41.  
  42.  
  43.  
  44. function TFPC_FLHost.Dispatcher(Sender:Integer;ID,Index,Value:Integer):Integer;
  45. //    mov eax,self; mov eax,[eax+FLHost];mov eax,[eax];pop ebp
  46. //    jmp [eax]//+vmtoffset ComputeLRVol_Old]
  47.  
  48. var
  49.   i:integer;
  50.   Notes: PNotesParams;
  51. begin
  52.       // FHD_AddNotesToPR (17)
  53.   //   writeln ('FPC->Dispatcher ID: ', ID);
  54.      if ID = FHD_AddNotesToPR then begin
  55.       Notes := PNotesParams(Value);
  56.  
  57.  
  58.      for i := 0 to Notes.Count-1 do begin
  59.  
  60.        writeln ('Note: ',i, ' ', Notes.NoteParams[i].Position div (TimeInfo.PPQ div 16 )  );
  61.      // writeln ('Notes: ', Notes.Count);
  62.  
  63.       end;
  64.          Notes.Target := 0;
  65.         //writeln ('Time PPQ:  ',  TimeInfo.PPQ);
  66.      end;//FHD_AddNotesToPR
  67.      result := FLHost.Dispatcher(Sender,ID,Index,Value);
  68. end;                                  
  69.  
  70.  
  71.  
  72. //{$define asm_code}
  73.  
  74. (*
  75. {$i qmidi}
  76.  
  77.  
  78. function TFruityPlugin.TriggerVoice(VoiceParams: PVoiceParams; SetTag: Integer): TVoiceHandle;
  79. var
  80.   port, p, Note, Vel, res, position, FCut,FRes, Color, i, msg : integer;
  81. //      TVoiceParams=Record
  82. //          InitLevels:TLevelParams;
  83. //          FinalLevels:TLevelParams;
  84. //        End;
  85.  
  86. begin
  87.  
  88.     Note := round_sse(@VoiceParams.InitLevels.Pitch);
  89.     Color :=  pInteger(SetTag + $1C)^ ;
  90.     Vel := integer(@VoiceParams.InitLevels.Vol);
  91.     Vel := pInteger(Vel)^;
  92.     Vel :=  qMidiVel (vel);// + random(30);
  93.  
  94.  
  95.  
  96. //   Vel := Vel - random (TSynthEditorForm(EditorForm).progress);
  97. //   if Vel < 0 then Vel := 125;
  98. //   if Vel > 125 then Vel := 125;
  99.  
  100.  
  101.  
  102.   port:=pInteger(integer(DashBoard_FruityPlug) + $0EC)^;
  103.   msg := (port shl 24) or $90;
  104.  
  105.   msg := msg  or (byte(Note ) shl 8 )  or (byte(Vel) shl 16);
  106.  
  107.   //(*  $00000090
  108.  
  109. //  msg := msg or $90;
  110.      //  if port <> -1 then  
  111.      // if (msg and $FF000000) <> (port shl 24 ) then exit;
  112.  
  113.  
  114. {
  115.   writeln (clock,' TVoise:'
  116.          , ' N: ', Note // div 100 //);
  117.          , ' V: ', VolToMIDIVel(@VoiceParams.InitLevels.Vol)
  118.          , '   ',   qMidiVel (vel)
  119. //VolToMIDIVel2(@VoiceParams.InitLevels.Vol)
  120.  
  121.      //    , ' Color: ', color
  122.  );  
  123. }
  124.  
  125.  //MidiIn (msg);
  126.        //!!!
  127.        PlugHost.MIDIOut_Delayed (HostTag,msg);
  128.   voicetag[note] := SetTag;
  129.  
  130.   Result := TVoiceHandle(integer(@voicetag[note]));
  131.               //   MidiIn (msg);
  132.  
  133. end;
  134.  
  135.  
  136. procedure TFruityPlugin.Voice_Kill(Handle: TVoiceHandle);
  137. begin
  138. end;
  139.  
  140. procedure TFruityPlugin.Voice_Release(Handle: TVoiceHandle);
  141. var port,i,Note,msg : integer;
  142. begin
  143.      Note := (handle - integer(@voicetag)) div  4;
  144.  
  145.    //   port:=pInteger(integer(DashBoard_FruityPlug) + $0EC)^;
  146.  
  147.       port:=pInteger(integer(DashBoard_FruityPlug) + $0EC)^;
  148.       msg := (port shl 24) or $80;
  149.      //msg := $01400080 or (Note shl 8 );
  150.           PlugHost.MIDIOut_Delayed (HostTag,msg);
  151.  
  152. //    MidiIn (msg);
  153.  
  154.    PlugHost.Voice_Kill(pInteger(Handle)^, true);
  155.  
  156. end;
  157.  
  158.  
  159. *)
  160.  
  161.  
  162.  
  163.  
  164. function TFruityPlugin.TriggerVoice(VoiceParams: PVoiceParams; SetTag: Integer): TVoiceHandle;
  165. begin
  166.   VoiceParams.InitLevels.Vol := VoiceParams.InitLevels.Vol + (-0.5 + random );
  167.   result :=  FPC_FruityPlug.TriggerVoice(VoiceParams, SetTag);
  168. end;
  169.  
  170.  
  171. procedure TFruityPlugin.Voice_Kill(Handle: TVoiceHandle);
  172. begin
  173.      FPC_FruityPlug.Voice_Kill(Handle);
  174. end;
  175.  
  176.  
  177. procedure TFruityPlugin.Voice_Release(Handle: TVoiceHandle);
  178. begin
  179.     FPC_FruityPlug.Voice_Release(Handle);
  180. end;
  181.  
  182. {$endif}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement