Commit 66781d3

Nick committed on
Choose format from filename manually rather than relying on FFMPEG
commit 66781d3f42bda09f39107a2fbce71fdd2efe20bf parent 0cb68e9
3 changed files +108−68
ModifiedhUGEDriver +1−1
@@ -1 +1 @@
1 Subproject commit 96bbed47fbe93e35fca597e5ac87d99ff5725935 1 Subproject commit 6598b2ce451b1c09ccd53bbffb53fb2681048700
Modifiedrendertowave.lfm +81−58
@@ -1,20 +1,21 @@
1 object frmRenderToWave: TfrmRenderToWave 1 object frmRenderToWave: TfrmRenderToWave
2 Left = 1811 2 Left = 2188
3 Height = 219 3 Height = 365
4 Top = 240 4 Top = 290
5 Width = 451 5 Width = 789
6 BorderStyle = bsSingle 6 BorderStyle = bsSingle
7 Caption = 'Render song' 7 Caption = 'Render song'
8 ClientHeight = 219 8 ClientHeight = 365
9 ClientWidth = 451 9 ClientWidth = 789
10 DesignTimePPI = 168
10 OnShow = FormShow 11 OnShow = FormShow
11 Position = poDefault 12 Position = poDefault
12 LCLVersion = '2.0.11.0' 13 LCLVersion = '2.0.12.0'
13 object RenderButton: TButton 14 object RenderButton: TButton
14 Left = 16 15 Left = 24
15 Height = 25 16 Height = 44
16 Top = 176 17 Top = 289
17 Width = 264 18 Width = 462
18 Caption = 'Render' 19 Caption = 'Render'
19 Enabled = False 20 Enabled = False
20 OnClick = RenderButtonClick 21 OnClick = RenderButtonClick
@@ -22,15 +23,14 @@ object frmRenderToWave: TfrmRenderToWave
22 TabOrder = 0 23 TabOrder = 0
23 end 24 end
24 object FileNameEdit1: TFileNameEdit 25 object FileNameEdit1: TFileNameEdit
25 Left = 80 26 Left = 140
26 Height = 23 27 Height = 38
27 Top = 8 28 Top = 14
28 Width = 353 29 Width = 402
29 OnAcceptFileName = FileNameEdit1AcceptFileName 30 Filter = 'Wave|*.wav|MP3|*.mp3|FLAC|*.flac'
30 Filter = 'Wave|*.wav|Ogg Vorbis|*.ogg|MP3|*.mp3|FLAC|*.flac|AAC|*.aac'
31 FilterIndex = 0 31 FilterIndex = 0
32 HideDirectories = False 32 HideDirectories = False
33 ButtonWidth = 23 33 ButtonWidth = 40
34 NumGlyphs = 1 34 NumGlyphs = 1
35 MaxLength = 0 35 MaxLength = 0
36 ParentFont = False 36 ParentFont = False
@@ -38,28 +38,28 @@ object frmRenderToWave: TfrmRenderToWave
38 OnChange = FileNameEdit1Change 38 OnChange = FileNameEdit1Change
39 end 39 end
40 object Label1: TLabel 40 object Label1: TLabel
41 Left = 16 41 Left = 24
42 Height = 15 42 Height = 30
43 Top = 16 43 Top = 22
44 Width = 48 44 Width = 83
45 Caption = 'Filename' 45 Caption = 'Filename'
46 ParentColor = False 46 ParentColor = False
47 ParentFont = False 47 ParentFont = False
48 end 48 end
49 object ProgressBar1: TProgressBar 49 object ProgressBar1: TProgressBar
50 Left = 16 50 Left = 24
51 Height = 28 51 Height = 49
52 Top = 136 52 Top = 219
53 Width = 417 53 Width = 730
54 ParentFont = False 54 ParentFont = False
55 Smooth = True 55 Smooth = True
56 TabOrder = 2 56 TabOrder = 2
57 end 57 end
58 object CancelButton: TButton 58 object CancelButton: TButton
59 Left = 287 59 Left = 498
60 Height = 25 60 Height = 44
61 Top = 176 61 Top = 289
62 Width = 146 62 Width = 256
63 Caption = 'Cancel' 63 Caption = 'Cancel'
64 Enabled = False 64 Enabled = False
65 OnClick = CancelButtonClick 65 OnClick = CancelButtonClick
@@ -67,62 +67,85 @@ object frmRenderToWave: TfrmRenderToWave
67 TabOrder = 3 67 TabOrder = 3
68 end 68 end
69 object PlayEntireSongRadioButton: TRadioButton 69 object PlayEntireSongRadioButton: TRadioButton
70 Left = 16 70 Left = 24
71 Height = 19 71 Height = 34
72 Top = 56 72 Top = 79
73 Width = 104 73 Width = 182
74 Caption = 'Play entire song' 74 Caption = 'Play entire song'
75 Checked = True 75 Checked = True
76 ParentFont = False
76 TabOrder = 8 77 TabOrder = 8
77 TabStop = True 78 TabStop = True
78 end 79 end
79 object FromPositionRadioButton: TRadioButton 80 object FromPositionRadioButton: TRadioButton
80 Left = 16 81 Left = 24
81 Height = 19 82 Height = 34
82 Top = 96 83 Top = 149
83 Width = 94 84 Width = 161
84 Caption = 'From position' 85 Caption = 'From position'
86 ParentFont = False
85 TabOrder = 7 87 TabOrder = 7
86 end 88 end
87 object PlayEntireSongSpinEdit: TSpinEdit 89 object PlayEntireSongSpinEdit: TSpinEdit
88 Left = 136 90 Left = 234
89 Height = 23 91 Height = 38
90 Top = 52 92 Top = 72
91 Width = 98 93 Width = 172
92 MinValue = 1 94 MinValue = 1
95 ParentFont = False
93 TabOrder = 4 96 TabOrder = 4
94 Value = 1 97 Value = 1
95 end 98 end
96 object Label2: TLabel 99 object Label2: TLabel
97 Left = 248 100 Left = 430
98 Height = 15 101 Height = 30
99 Top = 58 102 Top = 83
100 Width = 29 103 Width = 50
101 Caption = 'times' 104 Caption = 'times'
102 ParentColor = False 105 ParentColor = False
106 ParentFont = False
103 end 107 end
104 object FromPositionLowerSpinEdit: TSpinEdit 108 object FromPositionLowerSpinEdit: TSpinEdit
105 Left = 136 109 Left = 234
106 Height = 23 110 Height = 38
107 Top = 92 111 Top = 142
108 Width = 72 112 Width = 126
109 MaxValue = 9999999 113 MaxValue = 9999999
114 ParentFont = False
110 TabOrder = 5 115 TabOrder = 5
111 end 116 end
112 object FromPositionUpperSpinEdit: TSpinEdit 117 object FromPositionUpperSpinEdit: TSpinEdit
113 Left = 256 118 Left = 444
114 Height = 23 119 Height = 38
115 Top = 92 120 Top = 142
116 Width = 72 121 Width = 126
117 MaxValue = 99999999 122 MaxValue = 99999999
123 ParentFont = False
118 TabOrder = 6 124 TabOrder = 6
119 end 125 end
120 object Label3: TLabel 126 object Label3: TLabel
121 Left = 226 127 Left = 392
122 Height = 15 128 Height = 30
123 Top = 98 129 Top = 153
124 Width = 11 130 Width = 19
125 Caption = 'to' 131 Caption = 'to'
126 ParentColor = False 132 ParentColor = False
133 ParentFont = False
134 end
135 object ComboBox1: TComboBox
136 Left = 560
137 Height = 38
138 Top = 14
139 Width = 207
140 ItemHeight = 30
141 ItemIndex = 0
142 Items.Strings = (
143 'Wave'
144 'MP3'
145 'FLAC'
146 )
147 Style = csDropDownList
148 TabOrder = 9
149 Text = 'Wave'
127 end 150 end
128 end 151 end
Modifiedrendertowave.pas +26−9
@@ -16,6 +16,7 @@ type
16 { TfrmRenderToWave } 16 { TfrmRenderToWave }
17 17
18 TfrmRenderToWave = class(TForm) 18 TfrmRenderToWave = class(TForm)
19 ComboBox1: TComboBox;
19 Label2: TLabel; 20 Label2: TLabel;
20 Label3: TLabel; 21 Label3: TLabel;
21 PlayEntireSongRadioButton: TRadioButton; 22 PlayEntireSongRadioButton: TRadioButton;
@@ -30,7 +31,6 @@ type
30 FromPositionUpperSpinEdit: TSpinEdit; 31 FromPositionUpperSpinEdit: TSpinEdit;
31 procedure CancelButtonClick(Sender: TObject); 32 procedure CancelButtonClick(Sender: TObject);
32 procedure RenderButtonClick(Sender: TObject); 33 procedure RenderButtonClick(Sender: TObject);
33 procedure FileNameEdit1AcceptFileName(Sender: TObject; var Value: String);
34 procedure FileNameEdit1Change(Sender: TObject); 34 procedure FileNameEdit1Change(Sender: TObject);
35 procedure FormShow(Sender: TObject); 35 procedure FormShow(Sender: TObject);
36 private 36 private
@@ -40,12 +40,12 @@ type
40 Rendering: Boolean; 40 Rendering: Boolean;
41 CancelRequested: Boolean; 41 CancelRequested: Boolean;
42 42
43 function FilenameToFormatIndex: Integer;
44 function GetFFMPEGFormat: String;
43 procedure UpdateButtonEnabledStates; 45 procedure UpdateButtonEnabledStates;
44 46
45 procedure ExportWaveToFile(Filename: String); 47 procedure ExportWaveToFile(Filename: String);
46 48
47 {procedure RenderSeconds(Seconds: Integer);
48 procedure RenderLoops(TargetOrder: Integer; Loops: Integer);}
49 procedure RenderEntireSong(Times: Integer); 49 procedure RenderEntireSong(Times: Integer);
50 procedure RenderFromPosition(FromPos, ToPos: Integer); 50 procedure RenderFromPosition(FromPos, ToPos: Integer);
51 51
@@ -63,12 +63,6 @@ uses sound, machine, mainloop, vars, symparser;
63 63
64 {$R *.lfm} 64 {$R *.lfm}
65 65
66 procedure TfrmRenderToWave.FileNameEdit1AcceptFileName(Sender: TObject;
67 var Value: String);
68 begin
69 UpdateButtonEnabledStates;
70 end;
71
72 procedure TfrmRenderToWave.RenderButtonClick(Sender: TObject); 66 procedure TfrmRenderToWave.RenderButtonClick(Sender: TObject);
73 begin 67 begin
74 ProgressBar1.Position := 0; 68 ProgressBar1.Position := 0;
@@ -99,6 +93,7 @@ end;
99 93
100 procedure TfrmRenderToWave.FileNameEdit1Change(Sender: TObject); 94 procedure TfrmRenderToWave.FileNameEdit1Change(Sender: TObject);
101 begin 95 begin
96 ComboBox1.ItemIndex := FilenameToFormatIndex;
102 UpdateButtonEnabledStates; 97 UpdateButtonEnabledStates;
103 end; 98 end;
104 99
@@ -112,6 +107,26 @@ begin
112 FromPositionUpperSpinEdit.Value:=0; 107 FromPositionUpperSpinEdit.Value:=0;
113 end; 108 end;
114 109
110 function TfrmRenderToWave.FilenameToFormatIndex: Integer;
111 begin
112 case LowerCase(ExtractFileExt(FileNameEdit1.FileName)) of
113 '.wav': Result := 0;
114 '.mp3': Result := 1;
115 '.flac': Result := 2;
116 else Result := 0;
117 end;
118 end;
119
120 function TfrmRenderToWave.GetFFMPEGFormat: String;
121 begin
122 case ComboBox1.ItemIndex of
123 0: Result := 'wav';
124 1: Result := 'mp3';
125 2: Result := 'flac';
126 else Result := 'wav';
127 end;
128 end;
129
115 procedure TfrmRenderToWave.UpdateButtonEnabledStates; 130 procedure TfrmRenderToWave.UpdateButtonEnabledStates;
116 begin 131 begin
117 RenderButton.Enabled := (FileNameEdit1.FileName <> '') and not Rendering; 132 RenderButton.Enabled := (FileNameEdit1.FileName <> '') and not Rendering;
@@ -149,6 +164,8 @@ begin
149 Add('2'); 164 Add('2');
150 Add('-i'); 165 Add('-i');
151 Add('-'); 166 Add('-');
167 Add('-f');
168 Add(GetFFMPEGFormat);
152 Add(Filename); 169 Add(Filename);
153 end; 170 end;
154 Proc.Options := [poUsePipes, poNoConsole]; 171 Proc.Options := [poUsePipes, poNoConsole];