📄 fmmainform.pas
字号:
if dialog.cbInitialTracksheet.Checked <> ShowInitialTracksheet then
begin
ShowInitialTracksheet := dialog.cbInitialTracksheet.Checked;
Registry.WriteBoolean (InitialTracksheetValue, ShowInitialTracksheet);
end;
// Save the new 'AutoSynchronize' value
if dialog.cbAutoSynchronize.Checked <> AutoSynchronize then
begin
AutoSynchronize := dialog.cbAutoSynchronize.Checked;
Registry.WriteBoolean (AutoSynchronizeValue, AutoSynchronize);
end;
if dialog.cbBoostPlaybackPriority.Checked <> MidiPlayer.BoostPriority then
begin
MidiPlayer.BoostPriority := dialog.cbBoostPlaybackPriority.Checked;
Registry.WriteBoolean (BoostPriorityValue, MidiPlayer.BoostPriority);
end;
if dialog.udDragNoteVolume.Position <> DragNoteVolume then
begin
DragNoteVolume := dialog.udDragNoteVolume.Position;
Registry.WriteInteger (DragNoteVolumeValue, DragNoteVolume)
end;
finally
registry.Free
end;
// Save the 'unselected' value in the input ports list
for i := 0 to dialog.lvUnselectedPorts.items.Count - 1 do
begin
idx := MidiInputPorts.IndexOf (dialog.lvUnselectedPorts.items.item [i].Caption);
if idx > -1 then
TBoolVal (MidiInputPorts.Objects [idx]).val := False
end;
// Save the 'selected' value in the input ports list
for i := 0 to dialog.lvSelectedPorts.items.Count - 1 do
begin
idx := MidiInputPorts.IndexOf (dialog.lvSelectedPorts.items.item [i].Caption);
if idx > -1 then
TBoolVal (MidiInputPorts.Objects [idx]).val := True
end;
// Save the active input ports registry keys.
registry := TReg.Create (HKEY_CURRENT_USER, ProgramKey + '\' + PropertiesKey + '\' + InputPortsKey, True);
try
for i := 0 to MidiInputPorts.Count - 1 do
begin
if TBoolVal (MidiInputPorts.Objects [i]).val then
Registry.WriteBoolean (MidiInputPorts.Strings [i], True)
else
try
Registry.DeleteValue (MidiInputPorts.Strings [i])
except
end
end
finally
Registry.free
end;
TrackOutputs.DefaultOutputPort := Dialog.DefaultPortNo ;
// Save the default output port.
with TReg.Create (HKEY_CURRENT_USER, ProgramKey + '\' + PropertiesKey + '\' + OutputPortsKey, True) do
try
WriteInteger (DefaultOutputPortValue, TrackOutputs.DefaultOutputPort);
finally
Free
end;
// Reload the instruments for each port, as these
// might have changed in the dialog...
for i := 0 to MidiOutputPorts.Count - 1 do
begin
OutputPort := TMidiOutputPortDetails (MidiOutputPorts.Items [i]);
if Assigned (outputPort.Instrument) then
begin
OutputPort.Instrument.Free;
OutputPort.Instrument := Nil;
SetOutputPrtInstrument (i, Nil)
end;
if OutputPort.InstrumentName <> '' then
try
with TFileStream.Create (OutputPort.InstrumentName, fmOpenRead) do
try
try
OutputPort.Instrument := TInstrument.Create (Nil);
ReadComponent (OutputPort.Instrument);
// Set the instrument cache (TMidiOutput.
// ** Todo - change the way instrument caching works
// - it's too messy
SetOutputPrtInstrument (i, OutputPort.Instrument);
except
end
finally
free
end
except
end
end;
ResetPatchNames;
// Replace the instrument (patch) names for all the
// tracks, in case we changed them above;
UpdateCurrentTrackDetails;
if Assigned (TracksheetForm) then TrackSheetForm.Notify;
end
finally
dialog.Free
end
end;
(*-------------------------------------------------------------------------*
| procedure TMainForm.FileExitClick |
| |
| Respond to 'Exit' events. |
| |
| Parameters: |
| Sender : TObject // The event sender |
*-------------------------------------------------------------------------*)
procedure TMainForm.FileExitClick(Sender: TObject);
begin
Close
end;
//==========================================================================
// View menu event handlers
(*-------------------------------------------------------------------------*
| procedure TMainForm.ViewTrackSheetClick |
| |
| Respond to 'View Tracksheet' events. |
| nb. Only allow one tracksheet, so toggle the form. The menu item gets |
| checked/unchecked in the tracksheet form's Show and Close event |
| handlers. The TracksheetForm variable gets set to nil in the |
| tracksheet form's Destroy handler. |
| |
| Parameters: |
| Sender : TObject // The event sender |
*-------------------------------------------------------------------------*)
procedure TMainForm.ViewTrackSheetClick(Sender: TObject);
begin
if Assigned (TracksheetForm) then // Already displayed
TracksheetForm.Close // .. Close it
else
begin // Not displayed. Display it.
TracksheetForm := TTracksheetForm.Create (self);
TracksheetForm.Show
end
end;
(*-------------------------------------------------------------------------*
| procedure TMainForm.ViewNoteEditorClick |
| |
| Respond to a ViewNoteEditor event. |
| |
| Parameters: |
| Sender : TObject // The event sender |
*-------------------------------------------------------------------------*)
procedure TMainForm.ViewNoteEditorClick(Sender: TObject);
begin
if Assigned (MidiData.Tracks [CurrentTrackNo]) then
TNoteEditorForm.Create (self).Show
end;
(*-------------------------------------------------------------------------*
| procedure TMainForm.ViewEventListClick |
| |
| Respond to a ViewEventList event. |
| |
| Parameters: |
| Sender : TObject // The event sender |
*-------------------------------------------------------------------------*)
procedure TMainForm.ViewEventListClick(Sender: TObject);
begin
if Assigned (MidiData.Tracks [CurrentTrackNo]) then
TEventListForm.Create (self).Show
end;
(*-------------------------------------------------------------------------*
| procedure TMainForm.ViewTempoMapClick |
| |
| Respond to a ViewTempoMap event. |
| |
| Parameters: |
| Sender : TObject // The event sender |
*-------------------------------------------------------------------------*)
procedure TMainForm.ViewTempoMapClick(Sender: TObject);
begin
if Assigned (MidiData.Tracks [0]) then
TTempoMapForm.Create (self).Show
end;
//==========================================================================
// Track menu event handlers
(*-------------------------------------------------------------------------*
| procedure TMainForm.TrackSelectClick |
| |
| Respond to a 'TrackSelec' event. This comes into it's own when there's |
| no track sheet displayed... |
| |
| Parameters: |
| Sender : TObject // The event sender |
*-------------------------------------------------------------------------*)
procedure TMainForm.TrackSelectClick(Sender: TObject);
var trackNo : Integer;
begin
trackNo := currentTrackNo;
if SelectTrackDialog (trackNo, False, True) then
begin
CurrentTrackNo := trackNo;
if Assigned (TracksheetForm) then
TracksheetForm.SelectTrack (trackNo);
end
end;
(*-------------------------------------------------------------------------*
| procedure TMainForm.TrackEraseAllClick |
| |
| Respond to a TrackEraseAll event |
| |
| Parameters: |
| Sender : TObject // The event sender |
*-------------------------------------------------------------------------*)
procedure TMainForm.TrackEraseAllClick(Sender: TObject);
begin
if Application.MessageBox ('Are you sure?', 'Erase All Events', mb_IconQuestion or mb_YesNo or mb_DefButton2) = IDYes then
begin
MidiData.EraseTrack (CurrentTrackNo);
// Update everything to display the new track info
NotifyAll
end
end;
(*-------------------------------------------------------------------------*
| procedure TMainForm.TrackKillClick |
| |
| Respond to a TrackKill event. |
| |
| Parameters: |
| Sender : TObject // The event sender |
*-------------------------------------------------------------------------*)
procedure TMainForm.TrackKillClick(Sender: TObject);
begin
if Application.MessageBox ('Are you sure?', 'Kill Track', mb_IconQuestion or mb_YesNo or mb_DefButton2) = IDYes then
begin
TrackOutputs [CurrentTrackNo].Free;
MidiData.RemoveTrack (CurrentTrackNo);
UpdateCurrentTrackDetails;
end
end;
(*-------------------------------------------------------------------------*
| procedure TMainForm.TrackStepModeRecordClick |
| |
| Respond to a Track/StepMode event |
| |
| Parameters: |
| Sender : TObject // The event sender |
*-------------------------------------------------------------------------*)
procedure TMainForm.TrackStepModeRecordClick(Sender: TObject);
begin
SetStepModeState (not TrackStepModeRecord.Checked);
if TrackStepModeRecord.Checked then
begin
StepModeForm := TStepModeForm.Create (self);
StepModeForm.Show
end
else StepModeForm.Close
end;
(*-------------------------------------------------------------------------*
| procedure TMainForm.TrackPropertiesClick |
| |
| Respond to a Track/Properties event |
| |
| Parameters: |
| Sender : TObject // The event sender |
*-------------------------------------------------------------------------*)
procedure TMainForm.TrackPropertiesClick(Sender: TObject);
begin
GetTrackProperties
end;
//==========================================================================
// Song menu event handlers
(*-------------------------------------------------------------------------*
| procedure TMainForm.SongPropertiesClick |
| |
| Respond to a Song/Properties event |
| |
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -