├── .gitattributes
├── .gitignore
├── CREDITS.md
├── Common.props
├── LICENSE
├── OutProcess
├── App.cpp
├── App.h
├── App_Waveform.cpp
├── CacheManager.cpp
├── CacheManager.h
├── Design.cpp
├── Design.h
├── MainDialog.cpp
├── MainDialog.h
├── MainWindow.cpp
├── MainWindow.h
├── MainWindow_Config.cpp
├── MainWindow_Layout.cpp
├── MainWindow_Mouse.cpp
├── MainWindow_OpenGL.cpp
├── MainWindow_Paint.cpp
├── Mode.cpp
├── Mode.h
├── Mode_BottomUp.cpp
├── Mode_Center.cpp
├── Mode_RMS.cpp
├── Mode_TopDown.cpp
├── OutProcess.cpp
├── OutProcess.h
├── OutProcess.rc
├── OutProcess.vcxproj
├── OutProcess.vcxproj.filters
├── ReaderManager.cpp
├── ReaderManager.h
├── WaiterManager.cpp
├── WaiterManager.h
├── framework.h
├── pch.cpp
├── pch.h
├── resource.h
└── targetver.h
├── README.md
├── ReaderProcess
├── App.h
├── Calc
│ ├── Hive.h
│ └── Worker.h
├── Plugin.cpp
├── Plugin.h
├── ReaderProcess.cpp
├── ReaderProcess.vcxproj
├── ReaderProcess.vcxproj.filters
├── framework.h
├── pch.cpp
├── pch.h
└── targetver.h
├── ShowWaveform.sln
└── ShowWaveform
├── App.cpp
├── App.h
├── FileCache.cpp
├── FileCache.h
├── ItemCache.cpp
├── ItemCache.h
├── MainDialog.cpp
├── MainDialog.h
├── Share.h
├── ShowWaveform.cpp
├── ShowWaveform.def
├── ShowWaveform.h
├── ShowWaveform.rc
├── ShowWaveform.vcxproj
├── ShowWaveform.vcxproj.filters
├── SubProcess.cpp
├── SubProcess.h
├── SubThread.cpp
├── SubThread.h
├── pch.cpp
├── pch.h
└── resource.h
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Oo]ut/
33 | [Ll]og/
34 | [Ll]ogs/
35 | _bin/
36 | _obj/
37 |
38 | # Visual Studio 2015/2017 cache/options directory
39 | .vs/
40 | # Uncomment if you have tasks that create the project's static files in wwwroot
41 | #wwwroot/
42 |
43 | # Visual Studio 2017 auto generated files
44 | Generated\ Files/
45 |
46 | # MSTest test Results
47 | [Tt]est[Rr]esult*/
48 | [Bb]uild[Ll]og.*
49 |
50 | # NUnit
51 | *.VisualState.xml
52 | TestResult.xml
53 | nunit-*.xml
54 |
55 | # Build Results of an ATL Project
56 | [Dd]ebugPS/
57 | [Rr]eleasePS/
58 | dlldata.c
59 |
60 | # Benchmark Results
61 | BenchmarkDotNet.Artifacts/
62 |
63 | # .NET Core
64 | project.lock.json
65 | project.fragment.lock.json
66 | artifacts/
67 |
68 | # ASP.NET Scaffolding
69 | ScaffoldingReadMe.txt
70 |
71 | # StyleCop
72 | StyleCopReport.xml
73 |
74 | # Files built by Visual Studio
75 | *_i.c
76 | *_p.c
77 | *_h.h
78 | *.ilk
79 | *.meta
80 | *.obj
81 | *.iobj
82 | *.pch
83 | *.pdb
84 | *.ipdb
85 | *.pgc
86 | *.pgd
87 | *.rsp
88 | *.sbr
89 | *.tlb
90 | *.tli
91 | *.tlh
92 | *.tmp
93 | *.tmp_proj
94 | *_wpftmp.csproj
95 | *.log
96 | *.vspscc
97 | *.vssscc
98 | .builds
99 | *.pidb
100 | *.svclog
101 | *.scc
102 |
103 | # Chutzpah Test files
104 | _Chutzpah*
105 |
106 | # Visual C++ cache files
107 | ipch/
108 | *.aps
109 | *.ncb
110 | *.opendb
111 | *.opensdf
112 | *.sdf
113 | *.cachefile
114 | *.VC.db
115 | *.VC.VC.opendb
116 |
117 | # Visual Studio profiler
118 | *.psess
119 | *.vsp
120 | *.vspx
121 | *.sap
122 |
123 | # Visual Studio Trace Files
124 | *.e2e
125 |
126 | # TFS 2012 Local Workspace
127 | $tf/
128 |
129 | # Guidance Automation Toolkit
130 | *.gpState
131 |
132 | # ReSharper is a .NET coding add-in
133 | _ReSharper*/
134 | *.[Rr]e[Ss]harper
135 | *.DotSettings.user
136 |
137 | # TeamCity is a build add-in
138 | _TeamCity*
139 |
140 | # DotCover is a Code Coverage Tool
141 | *.dotCover
142 |
143 | # AxoCover is a Code Coverage Tool
144 | .axoCover/*
145 | !.axoCover/settings.json
146 |
147 | # Coverlet is a free, cross platform Code Coverage Tool
148 | coverage*.json
149 | coverage*.xml
150 | coverage*.info
151 |
152 | # Visual Studio code coverage results
153 | *.coverage
154 | *.coveragexml
155 |
156 | # NCrunch
157 | _NCrunch_*
158 | .*crunch*.local.xml
159 | nCrunchTemp_*
160 |
161 | # MightyMoose
162 | *.mm.*
163 | AutoTest.Net/
164 |
165 | # Web workbench (sass)
166 | .sass-cache/
167 |
168 | # Installshield output folder
169 | [Ee]xpress/
170 |
171 | # DocProject is a documentation generator add-in
172 | DocProject/buildhelp/
173 | DocProject/Help/*.HxT
174 | DocProject/Help/*.HxC
175 | DocProject/Help/*.hhc
176 | DocProject/Help/*.hhk
177 | DocProject/Help/*.hhp
178 | DocProject/Help/Html2
179 | DocProject/Help/html
180 |
181 | # Click-Once directory
182 | publish/
183 |
184 | # Publish Web Output
185 | *.[Pp]ublish.xml
186 | *.azurePubxml
187 | # Note: Comment the next line if you want to checkin your web deploy settings,
188 | # but database connection strings (with potential passwords) will be unencrypted
189 | *.pubxml
190 | *.publishproj
191 |
192 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
193 | # checkin your Azure Web App publish settings, but sensitive information contained
194 | # in these scripts will be unencrypted
195 | PublishScripts/
196 |
197 | # NuGet Packages
198 | *.nupkg
199 | # NuGet Symbol Packages
200 | *.snupkg
201 | # The packages folder can be ignored because of Package Restore
202 | **/[Pp]ackages/*
203 | # except build/, which is used as an MSBuild target.
204 | !**/[Pp]ackages/build/
205 | # Uncomment if necessary however generally it will be regenerated when needed
206 | #!**/[Pp]ackages/repositories.config
207 | # NuGet v3's project.json files produces more ignorable files
208 | *.nuget.props
209 | *.nuget.targets
210 |
211 | # Microsoft Azure Build Output
212 | csx/
213 | *.build.csdef
214 |
215 | # Microsoft Azure Emulator
216 | ecf/
217 | rcf/
218 |
219 | # Windows Store app package directories and files
220 | AppPackages/
221 | BundleArtifacts/
222 | Package.StoreAssociation.xml
223 | _pkginfo.txt
224 | *.appx
225 | *.appxbundle
226 | *.appxupload
227 |
228 | # Visual Studio cache files
229 | # files ending in .cache can be ignored
230 | *.[Cc]ache
231 | # but keep track of directories ending in .cache
232 | !?*.[Cc]ache/
233 |
234 | # Others
235 | ClientBin/
236 | ~$*
237 | *~
238 | *.dbmdl
239 | *.dbproj.schemaview
240 | *.jfm
241 | *.pfx
242 | *.publishsettings
243 | orleans.codegen.cs
244 |
245 | # Including strong name files can present a security risk
246 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
247 | #*.snk
248 |
249 | # Since there are multiple workflows, uncomment next line to ignore bower_components
250 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
251 | #bower_components/
252 |
253 | # RIA/Silverlight projects
254 | Generated_Code/
255 |
256 | # Backup & report files from converting an old project file
257 | # to a newer Visual Studio version. Backup files are not needed,
258 | # because we have git ;-)
259 | _UpgradeReport_Files/
260 | Backup*/
261 | UpgradeLog*.XML
262 | UpgradeLog*.htm
263 | ServiceFabricBackup/
264 | *.rptproj.bak
265 |
266 | # SQL Server files
267 | *.mdf
268 | *.ldf
269 | *.ndf
270 |
271 | # Business Intelligence projects
272 | *.rdl.data
273 | *.bim.layout
274 | *.bim_*.settings
275 | *.rptproj.rsuser
276 | *- [Bb]ackup.rdl
277 | *- [Bb]ackup ([0-9]).rdl
278 | *- [Bb]ackup ([0-9][0-9]).rdl
279 |
280 | # Microsoft Fakes
281 | FakesAssemblies/
282 |
283 | # GhostDoc plugin setting file
284 | *.GhostDoc.xml
285 |
286 | # Node.js Tools for Visual Studio
287 | .ntvs_analysis.dat
288 | node_modules/
289 |
290 | # Visual Studio 6 build log
291 | *.plg
292 |
293 | # Visual Studio 6 workspace options file
294 | *.opt
295 |
296 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
297 | *.vbw
298 |
299 | # Visual Studio LightSwitch build output
300 | **/*.HTMLClient/GeneratedArtifacts
301 | **/*.DesktopClient/GeneratedArtifacts
302 | **/*.DesktopClient/ModelManifest.xml
303 | **/*.Server/GeneratedArtifacts
304 | **/*.Server/ModelManifest.xml
305 | _Pvt_Extensions
306 |
307 | # Paket dependency manager
308 | .paket/paket.exe
309 | paket-files/
310 |
311 | # FAKE - F# Make
312 | .fake/
313 |
314 | # CodeRush personal settings
315 | .cr/personal
316 |
317 | # Python Tools for Visual Studio (PTVS)
318 | __pycache__/
319 | *.pyc
320 |
321 | # Cake - Uncomment if you are using it
322 | # tools/**
323 | # !tools/packages.config
324 |
325 | # Tabs Studio
326 | *.tss
327 |
328 | # Telerik's JustMock configuration file
329 | *.jmconfig
330 |
331 | # BizTalk build output
332 | *.btp.cs
333 | *.btm.cs
334 | *.odx.cs
335 | *.xsd.cs
336 |
337 | # OpenCover UI analysis results
338 | OpenCover/
339 |
340 | # Azure Stream Analytics local run output
341 | ASALocalRun/
342 |
343 | # MSBuild Binary and Structured Log
344 | *.binlog
345 |
346 | # NVidia Nsight GPU debugger configuration file
347 | *.nvuser
348 |
349 | # MFractors (Xamarin productivity tool) working folder
350 | .mfractor/
351 |
352 | # Local History for Visual Studio
353 | .localhistory/
354 |
355 | # BeatPulse healthcheck temp database
356 | healthchecksdb
357 |
358 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
359 | MigrationBackup/
360 |
361 | # Ionide (cross platform F# VS Code tools) working folder
362 | .ionide/
363 |
364 | # Fody - auto-generated XML schema
365 | FodyWeavers.xsd
--------------------------------------------------------------------------------
/CREDITS.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hebiiro/AviUtl-Plugin-ShowWaveform/ada292c648f8d941588c9261710214e157c187ef/CREDITS.md
--------------------------------------------------------------------------------
/Common.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $(UserProfile)\source
6 | $(my_source)\packages
7 |
8 |
9 | $(SolutionDir)_bin\
10 | $(SolutionDir)_obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\
11 |
12 |
13 |
14 | $(IntDir)
15 |
16 |
17 |
18 |
19 | $(IntDir)
20 | $(my_packages)\detours.4.0.1;$(my_packages)\glad.2.0.4;$(my_packages)\nanovg.rgb2hsv;$(my_packages)\aviutl_exedit_sdk;$(my_packages)\my;%(AdditionalIncludeDirectories)
21 |
22 |
23 | $(my_packages)\detours.4.0.1;$(my_packages)\nanovg.rgb2hsv;%(AdditionalLibraryDirectories)
24 |
25 |
26 |
27 |
28 | $(my_source)
29 |
30 |
31 | $(my_packages)
32 |
33 |
34 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 hebiiro
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/OutProcess/App.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 | #include "App.h"
3 | #include "Common/Tracer2.h"
4 |
5 | //--------------------------------------------------------------------
6 |
7 | App theApp;
8 | Shared shared;
9 |
10 | //--------------------------------------------------------------------
11 |
12 | BOOL App::getShowBPM()
13 | {
14 | return mainWindow.getShowBPM();
15 | }
16 |
17 | BOOL App::setShowBPM(BOOL newShowBPM)
18 | {
19 | if (!mainWindow.setShowBPM(newShowBPM))
20 | return FALSE;
21 |
22 | mainDialog.ignoreNotification(TRUE);
23 | mainDialog.setShowBPM(mainWindow.getShowBPM());
24 | mainDialog.ignoreNotification(FALSE);
25 |
26 | return TRUE;
27 | }
28 |
29 | int App::getOrig()
30 | {
31 | return mainWindow.getOrig();
32 | }
33 |
34 | BOOL App::setOrig(int newOrig)
35 | {
36 | if (!mainWindow.setOrig(newOrig))
37 | return FALSE;
38 |
39 | mainDialog.ignoreNotification(TRUE);
40 | mainDialog.setOrig(mainWindow.getOrig());
41 | mainDialog.ignoreNotification(FALSE);
42 |
43 | return TRUE;
44 | }
45 |
46 | int App::getBPM()
47 | {
48 | return mainWindow.getBPM();
49 | }
50 |
51 | BOOL App::setBPM(int newBPM)
52 | {
53 | if (!mainWindow.setBPM(newBPM))
54 | return FALSE;
55 |
56 | mainDialog.ignoreNotification(TRUE);
57 | mainDialog.setBPM(mainWindow.getBPM());
58 | mainDialog.ignoreNotification(FALSE);
59 |
60 | return TRUE;
61 | }
62 |
63 | int App::getAbove()
64 | {
65 | return mainWindow.getAbove();
66 | }
67 |
68 | BOOL App::setAbove(int newAbove)
69 | {
70 | if (!mainWindow.setAbove(newAbove))
71 | return FALSE;
72 |
73 | mainDialog.ignoreNotification(TRUE);
74 | mainDialog.setAbove(mainWindow.getAbove());
75 | mainDialog.ignoreNotification(FALSE);
76 |
77 | return TRUE;
78 | }
79 |
80 | int App::getBelow()
81 | {
82 | return mainWindow.getBelow();
83 | }
84 |
85 | BOOL App::setBelow(int newBelow)
86 | {
87 | if (!mainWindow.setBelow(newBelow))
88 | return FALSE;
89 |
90 | mainDialog.ignoreNotification(TRUE);
91 | mainDialog.setBelow(mainWindow.getBelow());
92 | mainDialog.ignoreNotification(FALSE);
93 |
94 | return TRUE;
95 | }
96 |
97 | int App::getLimitVolume()
98 | {
99 | return mainWindow.getLimitVolume();
100 | }
101 |
102 | BOOL App::setLimitVolume(int newLimitVolume)
103 | {
104 | if (!mainWindow.setLimitVolume(newLimitVolume))
105 | return FALSE;
106 |
107 | mainDialog.ignoreNotification(TRUE);
108 | mainDialog.setLimitVolume(mainWindow.getLimitVolume());
109 | mainDialog.ignoreNotification(FALSE);
110 |
111 | return TRUE;
112 | }
113 |
114 | int App::getBaseVolume()
115 | {
116 | return mainWindow.getBaseVolume();
117 | }
118 |
119 | BOOL App::setBaseVolume(int newBaseVolume)
120 | {
121 | if (!mainWindow.setBaseVolume(newBaseVolume))
122 | return FALSE;
123 |
124 | mainDialog.ignoreNotification(TRUE);
125 | mainDialog.setBaseVolume(mainWindow.getBaseVolume());
126 | mainDialog.ignoreNotification(FALSE);
127 |
128 | return TRUE;
129 | }
130 |
131 | int App::getMinRMS()
132 | {
133 | return mainWindow.getMinRMS();
134 | }
135 |
136 | BOOL App::setMinRMS(int newMinRMS)
137 | {
138 | if (!mainWindow.setMinRMS(newMinRMS))
139 | return FALSE;
140 |
141 | mainDialog.ignoreNotification(TRUE);
142 | mainDialog.setMinRMS(mainWindow.getMinRMS());
143 | mainDialog.ignoreNotification(FALSE);
144 |
145 | return TRUE;
146 | }
147 |
148 | int App::getMaxRMS()
149 | {
150 | return mainWindow.getMaxRMS();
151 | }
152 |
153 | BOOL App::setMaxRMS(int newMaxRMS)
154 | {
155 | if (!mainWindow.setMaxRMS(newMaxRMS))
156 | return FALSE;
157 |
158 | mainDialog.ignoreNotification(TRUE);
159 | mainDialog.setMaxRMS(mainWindow.getMaxRMS());
160 | mainDialog.ignoreNotification(FALSE);
161 |
162 | return TRUE;
163 | }
164 |
165 | int App::getBaseRMS()
166 | {
167 | return mainWindow.getBaseRMS();
168 | }
169 |
170 | BOOL App::setBaseRMS(int newBaseRMS)
171 | {
172 | if (!mainWindow.setBaseRMS(newBaseRMS))
173 | return FALSE;
174 |
175 | mainDialog.ignoreNotification(TRUE);
176 | mainDialog.setBaseRMS(mainWindow.getBaseRMS());
177 | mainDialog.ignoreNotification(FALSE);
178 |
179 | return TRUE;
180 | }
181 |
182 | int App::getZoom()
183 | {
184 | return mainWindow.getZoom();
185 | }
186 |
187 | BOOL App::setZoom(int newZoom)
188 | {
189 | if (!mainWindow.setZoom(newZoom))
190 | return FALSE;
191 |
192 | mainDialog.ignoreNotification(TRUE);
193 | mainDialog.setZoom(mainWindow.getZoom());
194 | mainDialog.ignoreNotification(FALSE);
195 |
196 | return TRUE;
197 | }
198 |
199 | //--------------------------------------------------------------------
200 |
201 | void CALLBACK App::timerProc(HWND hwnd, UINT message, UINT_PTR timerId, DWORD time)
202 | {
203 | if (!::IsWindow(theApp.windowContainer))
204 | {
205 | MY_TRACE(_T("コンテナウィンドウが無効になりました\n"));
206 |
207 | ::PostQuitMessage(0);
208 | }
209 | }
210 |
211 | int APIENTRY App::WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR cmdLine, int cmdShow)
212 | {
213 | struct Initializer
214 | {
215 | Initializer()
216 | {
217 | _tsetlocale(LC_ALL, _T(""));
218 | trace_init(0, 0, TRUE);
219 | ::OleInitialize(0);
220 | }
221 |
222 | ~Initializer()
223 | {
224 | trace_term();
225 | ::OleUninitialize();
226 | }
227 |
228 | } initializer;
229 |
230 | MY_TRACE(_T("WinMain()\n"));
231 |
232 | windowContainer = (HWND)_tcstoull(::GetCommandLine(), 0, 0);
233 | MY_TRACE_HEX(windowContainer);
234 |
235 | dialogContainer = (HWND)::GetProp(windowContainer, PROP_NAME_DIALOG_CONTAINER);
236 | MY_TRACE_HEX(dialogContainer);
237 |
238 | if (!shared.init(windowContainer))
239 | {
240 | ::MessageBox(windowContainer, _T("共有メモリの初期化に失敗しました"), _T("ShowWaveform.OutProcess"), MB_OK);
241 | return -1;
242 | }
243 |
244 | if (!mainWindow.create(instance, windowContainer))
245 | {
246 | ::MessageBox(windowContainer, _T("メインウィンドウの作成に失敗しました"), _T("ShowWaveform.OutProcess"), MB_OK);
247 | return -1;
248 | }
249 |
250 | MY_TRACE_HWND((HWND)mainWindow);
251 |
252 | if (!mainDialog.create(instance, dialogContainer))
253 | {
254 | ::MessageBox(windowContainer, _T("メインダイアログの作成に失敗しました"), _T("ShowWaveform.OutProcess"), MB_OK);
255 | return -1;
256 | }
257 |
258 | MY_TRACE_HWND((HWND)mainDialog);
259 |
260 | // InProcess にウィンドウハンドルを渡す。
261 | ::PostMessage(windowContainer, WM_AVIUTL_FILTER_INIT, (WPARAM)(HWND)mainWindow, 0);
262 | ::PostMessage(dialogContainer, WM_AVIUTL_FILTER_INIT, (WPARAM)(HWND)mainDialog, 0);
263 |
264 | // InProcess を監視するタイマーを作成する。
265 | // メインウィンドウは削除されるかもしれないので WM_TIMER は使用できない。
266 | ::SetTimer(0, 0, 1000, timerProc);
267 |
268 | MSG msg = {};
269 | while (::GetMessage(&msg, 0, 0, 0))
270 | {
271 | ::TranslateMessage(&msg);
272 | ::DispatchMessage(&msg);
273 | }
274 |
275 | shared.term();
276 |
277 | MY_TRACE(_T("プロセスが正常終了しました\n"));
278 |
279 | return 0;
280 | }
281 |
282 | LRESULT App::onAviUtlFilterSend(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
283 | {
284 | MY_TRACE(_T("onAviUtlFilterSend(0x%08X, 0x%08X)\n"), wParam, lParam);
285 |
286 | switch (wParam)
287 | {
288 | case SendID::requestCache:
289 | {
290 | SenderBottlePtr bottle = shared.getSenderBottle();
291 | if (bottle)
292 | {
293 | CachePtr cache = cacheManager.getCache(bottle->fileName);
294 | if (cache)
295 | {
296 | // キャッシュが作成済みならメインプロセスに通知する。
297 | sendCache(cache);
298 | }
299 | else
300 | {
301 | // キャッシュが存在しないので新規作成する。
302 | // (1) ファイル名からウェイターを作成する。
303 | // (2) ウェイターからリーダーを作成する。
304 | // (3) リーダーからキャッシュを作成する。
305 |
306 | // ウェイターを作成する。
307 | WaiterPtr waiter = waiterManager.createWaiter(bottle->fileName);
308 |
309 | // 可能であれば、ウェイターを消化する。
310 | waiterManager.digestWaiterQueue(readerManager);
311 | }
312 | }
313 |
314 | break;
315 | }
316 | case SendID::notifyProjectChanged:
317 | {
318 | ProjectParamsPtr params = shared.getProjectParams();
319 | if (params)
320 | setProjectParams(params);
321 |
322 | break;
323 | }
324 | case SendID::notifyItemChanged:
325 | {
326 | AudioParamsPtr params = shared.getAudioParams();
327 | if (params)
328 | setAudioParams(params);
329 |
330 | break;
331 | }
332 | case SendID::notifyTotalsChanged:
333 | {
334 | TotalsParamsPtr params = shared.getSenderTotalsParams();
335 | if (params)
336 | setTotalsParams(params);
337 |
338 | break;
339 | }
340 | }
341 |
342 | return 0;
343 | }
344 |
345 | LRESULT App::onAviUtlFilterReceive(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
346 | {
347 | MY_TRACE(_T("onAviUtlFilterReceive(0x%08X, 0x%08X)\n"), wParam, lParam);
348 |
349 | DWORD id = (DWORD)wParam;
350 | MY_TRACE_INT(id);
351 |
352 | // リーダーを取得する。
353 | ReaderPtr reader = readerManager.getReader(id);
354 | if (reader)
355 | {
356 | // キャッシュを作成する。
357 | CachePtr cache = cacheManager.createCache(reader);
358 | if (cache)
359 | {
360 | // キャッシュを作成できた場合はメインプロセスに通知する。
361 | sendCache(cache);
362 |
363 | // このリーダーは不要になったので削除する。
364 | readerManager.eraseReader(id);
365 |
366 | // リーダーの空きができたので次の読み込みを開始する。
367 | waiterManager.digestWaiterQueue(readerManager);
368 | }
369 | }
370 |
371 | return 0;
372 | }
373 |
374 | LRESULT App::onAviUtlFilterClear(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
375 | {
376 | MY_TRACE(_T("onAviUtlFilterClear(0x%08X, 0x%08X)\n"), wParam, lParam);
377 |
378 | cacheManager.clear();
379 |
380 | return 0;
381 | }
382 |
383 | LRESULT App::onAviUtlFilterRedraw(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
384 | {
385 | MY_TRACE(_T("onAviUtlFilterRedraw(0x%08X, 0x%08X)\n"), wParam, lParam);
386 |
387 | if (::IsWindowVisible(mainWindow))
388 | {
389 | // 全体の音声波形を再計算する。
390 | recalcTotals();
391 | }
392 |
393 | return 0;
394 | }
395 |
396 | //--------------------------------------------------------------------
397 |
398 | int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR cmdLine, int cmdShow)
399 | {
400 | return theApp.WinMain(instance, prevInstance, cmdLine, cmdShow);
401 | }
402 |
403 | //--------------------------------------------------------------------
404 |
--------------------------------------------------------------------------------
/OutProcess/App.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "CacheManager.h"
4 | #include "ReaderManager.h"
5 | #include "WaiterManager.h"
6 | #include "MainWindow.h"
7 | #include "MainDialog.h"
8 |
9 | //--------------------------------------------------------------------
10 |
11 | typedef std::map AudioParamsMap;
12 |
13 | struct Total {
14 | float level;
15 | float rms;
16 | };
17 |
18 | typedef std::vector Totals;
19 |
20 | //--------------------------------------------------------------------
21 |
22 | extern Shared shared;
23 |
24 | //--------------------------------------------------------------------
25 |
26 | struct App {
27 | HINSTANCE instance = 0;
28 | HWND windowContainer = 0;
29 | HWND dialogContainer = 0;
30 | CacheManager cacheManager;
31 | ReaderManager readerManager;
32 | WaiterManager waiterManager;
33 | MainWindow mainWindow;
34 | MainDialog mainDialog;
35 |
36 | BOOL getShowBPM();
37 | BOOL setShowBPM(BOOL newShowBPM);
38 | int getOrig();
39 | BOOL setOrig(int newOrig);
40 | int getBPM();
41 | BOOL setBPM(int newBPM);
42 | int getAbove();
43 | BOOL setAbove(int newAbove);
44 | int getBelow();
45 | BOOL setBelow(int newBelow);
46 |
47 | int getLimitVolume();
48 | BOOL setLimitVolume(int newLimitVolume);
49 | int getBaseVolume();
50 | BOOL setBaseVolume(int newBaseVolume);
51 | int getMinRMS();
52 | BOOL setMinRMS(int newMinRMS);
53 | int getMaxRMS();
54 | BOOL setMaxRMS(int newMaxRMS);
55 | int getBaseRMS();
56 | BOOL setBaseRMS(int newBaseRMS);
57 | int getZoom();
58 | BOOL setZoom(int newZoom);
59 |
60 | static void CALLBACK timerProc(HWND hwnd, UINT message, UINT_PTR timerId, DWORD time);
61 | int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR cmdLine, int cmdShow);
62 | LRESULT onAviUtlFilterSend(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
63 | LRESULT onAviUtlFilterReceive(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
64 | LRESULT onAviUtlFilterClear(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
65 | LRESULT onAviUtlFilterRedraw(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
66 |
67 | // App_Waveform
68 |
69 | Totals totals;
70 | ProjectParamsPtr projectParams;
71 | AudioParamsMap audioParamsMap;
72 |
73 | BOOL sendCache(const CachePtr& cache);
74 | BOOL recalcTotals();
75 | BOOL setProjectParams(const ProjectParamsPtr& params);
76 | BOOL setAudioParams(const AudioParamsPtr& params);
77 | BOOL setTotalsParams(const TotalsParamsPtr& params);
78 | };
79 |
80 | extern App theApp;
81 |
82 | //--------------------------------------------------------------------
83 |
--------------------------------------------------------------------------------
/OutProcess/App_Waveform.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 | #include "App.h"
3 |
4 | //--------------------------------------------------------------------
5 |
6 | // キャッシュをボトルに詰めてからメインプロセスに送る。(受け取るように促す)
7 | BOOL App::sendCache(const CachePtr& cache)
8 | {
9 | MY_TRACE(_T("App::sendCache(%hs)\n"), cache->fileName.c_str());
10 |
11 | ReceiverBottle* shared = ::shared.receiverBottle.getBuffer();
12 | MY_TRACE_HEX(shared);
13 | if (!shared) return FALSE;
14 |
15 | ::StringCbCopyA(shared->fileName, sizeof(shared->fileName), cache->fileName.c_str());
16 |
17 | shared->volumeCount = (int32_t)cache->volumes.size();
18 | MY_TRACE_INT(shared->volumeCount);
19 | memcpy(shared->volumes, cache->volumes.data(), sizeof(Volume) * cache->volumes.size());
20 |
21 | MY_TRACE_HEX(windowContainer);
22 | ::SendMessage(windowContainer, WM_AVIUTL_FILTER_RECEIVE, 0, 0);
23 |
24 | return TRUE;
25 | }
26 |
27 | BOOL App::recalcTotals()
28 | {
29 | MY_TRACE(_T("App::recalcTotals()\n"));
30 |
31 | // プロジェクトパラメータが有効かどうかチェックする。
32 | if (!projectParams) return FALSE;
33 | if (projectParams->frameNumber <= 0) return FALSE;
34 |
35 | // 全てのアイテムのキャッシュが作成済みかチェックする。
36 | for (auto pair : audioParamsMap)
37 | {
38 | const AudioParamsPtr& params = pair.second;
39 | if (params->sceneSet != projectParams->sceneIndex) continue;
40 | const CachePtr& cache = cacheManager.getCache(params->fileName);
41 | if (!cache) return FALSE;
42 | }
43 |
44 | // バッファを確保する。
45 | totals.resize(projectParams->frameNumber);
46 | memset(totals.data(), 0, sizeof(totals[0]) * totals.size());
47 |
48 | float scale = (float)Volume::Resolution * projectParams->video_scale / projectParams->video_rate;
49 | MY_TRACE_REAL(scale);
50 |
51 | for (auto pair : audioParamsMap)
52 | {
53 | const AudioParamsPtr& params = pair.second;
54 | if (params->sceneSet != projectParams->sceneIndex) continue;
55 | if (params->layerFlag & (uint32_t)ExEdit::LayerSetting::Flag::UnDisp) continue;
56 | const CachePtr& cache = cacheManager.getCache(params->fileName);
57 | if (!cache) continue;
58 |
59 | // 現在のフレームレートでの1フレーム毎の音量に変換する。
60 |
61 | int32_t frameBegin = params->frameBegin;
62 | int32_t frameEnd = std::min(params->frameEnd + 1, projectParams->frameNumber);
63 | int32_t frameRange = frameEnd - frameBegin;
64 | for (int32_t i = 0; i < frameRange; i++)
65 | {
66 | float temp1 = scale * params->playSpeed * i;
67 | float temp2 = scale * params->playBegin;
68 | int32_t src = (int32_t)(temp1 + temp2);
69 | int32_t dst = i + frameBegin;
70 |
71 | if (src < 0 || src >= (int32_t)cache->volumes.size())
72 | break;
73 |
74 | if (dst < 0 || dst >= (int32_t)totals.size())
75 | break;
76 |
77 | totals[dst].level += cache->volumes[src].level * params->volume;
78 | }
79 | }
80 |
81 | int c = (int)totals.size();
82 | MY_TRACE_INT(c);
83 | for (int i = 0; i < c; i++)
84 | {
85 | totals[i].rms = 20 * log10f(totals[i].level);
86 |
87 | // MY_TRACE(_T("%d : %f, %f\n"), i, totals[i].level, totals[i].rms);
88 | }
89 |
90 | mainWindow.recalcLayout();
91 | mainWindow.outputFrames();
92 | mainWindow.redraw();
93 |
94 | return TRUE;
95 | }
96 |
97 | BOOL App::setProjectParams(const ProjectParamsPtr& params)
98 | {
99 | MY_TRACE(_T("App::setProjectParams()\n"));
100 |
101 | if (projectParams &&
102 | projectParams->video_scale == params->video_scale &&
103 | projectParams->video_rate == params->video_rate &&
104 | projectParams->frameNumber == params->frameNumber &&
105 | projectParams->sceneIndex == params->sceneIndex)
106 | {
107 | MY_TRACE_INT(params->currentFrame);
108 |
109 | // カレントフレームが異なる場合は
110 | if (projectParams->currentFrame != params->currentFrame)
111 | {
112 | MY_TRACE(_T("カレントフレームが異なるので再描画します\n"));
113 |
114 | // カレントフレームを更新し、
115 | projectParams->currentFrame = params->currentFrame;
116 |
117 | // 再描画する。
118 | mainWindow.redraw();
119 |
120 | // カレントフレームをステータスボックスに出力する。
121 | mainWindow.outputFrames();
122 | }
123 |
124 | return FALSE;
125 | }
126 |
127 | projectParams = params;
128 | MY_TRACE_INT(projectParams->video_scale);
129 | MY_TRACE_INT(projectParams->video_rate);
130 | MY_TRACE_INT(projectParams->frameNumber);
131 | MY_TRACE_INT(projectParams->sceneIndex);
132 | MY_TRACE_INT(projectParams->currentFrame);
133 |
134 | if (::IsWindowVisible(mainWindow))
135 | {
136 | // 全体の音声波形を再計算する。
137 | recalcTotals();
138 | }
139 |
140 | return TRUE;
141 | }
142 |
143 | BOOL App::setAudioParams(const AudioParamsPtr& params)
144 | {
145 | MY_TRACE(_T("App::setAudioParams()\n"));
146 |
147 | MY_TRACE_STR(params->fileName);
148 | MY_TRACE_HEX(params->id);
149 | MY_TRACE_HEX(params->flag);
150 | MY_TRACE_INT(params->frameBegin);
151 | MY_TRACE_INT(params->frameEnd);
152 | MY_TRACE_INT(params->sceneSet);
153 | MY_TRACE_REAL(params->volume);
154 | MY_TRACE_INT(params->playBegin);
155 | MY_TRACE_REAL(params->playSpeed);
156 |
157 | if (params->flag & (uint32_t)ExEdit::Object::Flag::Exist)
158 | audioParamsMap[params->id] = params;
159 | else
160 | audioParamsMap.erase(params->id);
161 |
162 | if (::IsWindowVisible(mainWindow))
163 | {
164 | // 全体の音声波形を再計算する。
165 | recalcTotals();
166 | }
167 |
168 | return TRUE;
169 | }
170 |
171 | BOOL App::setTotalsParams(const TotalsParamsPtr& params)
172 | {
173 | MY_TRACE(_T("App::setTotalsParams()\n"));
174 |
175 | MY_TRACE_INT(params->showBPM);
176 | MY_TRACE_INT(params->tempo.orig);
177 | MY_TRACE_INT(params->tempo.bpm);
178 | MY_TRACE_INT(params->tempo.above);
179 | MY_TRACE_INT(params->tempo.below);
180 |
181 | setShowBPM(params->showBPM);
182 | setOrig(params->tempo.orig);
183 | setBPM(params->tempo.bpm);
184 | setAbove(params->tempo.above);
185 | setBelow(params->tempo.below);
186 | mainWindow.updateShared();
187 |
188 | if (::IsWindowVisible(mainWindow))
189 | {
190 | // 全体の音声波形を再描画する。
191 | mainWindow.redraw();
192 | }
193 |
194 | return TRUE;
195 | }
196 |
197 | //--------------------------------------------------------------------
198 |
--------------------------------------------------------------------------------
/OutProcess/CacheManager.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 | #include "CacheManager.h"
3 | #include "App.h"
4 |
5 | //--------------------------------------------------------------------
6 |
7 | CachePtr CacheManager::getCache(LPCSTR fileName)
8 | {
9 | MY_TRACE(_T("CacheManager::getCache(%hs)\n"), fileName);
10 |
11 | auto it = cacheMap.find(fileName);
12 | if (it == cacheMap.end()) return 0;
13 | return it->second;
14 | }
15 |
16 | // リーダーがボトルに詰め込んだ音量からキャッシュを作成する。
17 | CachePtr CacheManager::createCache(const ReaderPtr& reader)
18 | {
19 | MY_TRACE(_T("CacheManager::createCache()\n"));
20 |
21 | ReaderBottle* shared = reader->getBottle();
22 | if (!shared) return 0;
23 |
24 | MY_TRACE_STR(shared->fileName);
25 |
26 | CachePtr cache = std::make_shared();
27 | cache->fileName = shared->fileName;
28 | cache->volumes.insert(cache->volumes.end(),
29 | shared->volumes, shared->volumes + shared->volumeCount);
30 | cacheMap[cache->fileName] = cache;
31 | return cache;
32 | }
33 |
34 | void CacheManager::clear()
35 | {
36 | cacheMap.clear();
37 | }
38 |
39 | //--------------------------------------------------------------------
40 |
--------------------------------------------------------------------------------
/OutProcess/CacheManager.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "OutProcess.h"
4 | #include "ReaderManager.h"
5 |
6 | //--------------------------------------------------------------------
7 |
8 | struct Cache {
9 | std::string fileName;
10 | std::vector volumes;
11 | };
12 |
13 | typedef std::shared_ptr CachePtr;
14 | typedef std::map CacheMap;
15 |
16 | //--------------------------------------------------------------------
17 |
18 | struct CacheManager {
19 | CacheMap cacheMap;
20 |
21 | CachePtr getCache(LPCSTR fileName);
22 | CachePtr createCache(const ReaderPtr& reader);
23 | void clear();
24 | };
25 |
26 | //--------------------------------------------------------------------
27 |
--------------------------------------------------------------------------------
/OutProcess/Design.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "OutProcess.h"
4 |
5 | //--------------------------------------------------------------------
6 |
7 | struct XYWHRect
8 | {
9 | int x, y, w, h;
10 |
11 | XYWHRect()
12 | {
13 | x = y = w = h = 0;
14 | }
15 |
16 | XYWHRect(int x, int y, int w, int h)
17 | {
18 | this->x = x;
19 | this->y = y;
20 | this->w = w;
21 | this->h = h;
22 | }
23 |
24 | XYWHRect(const RECT& rc)
25 | {
26 | operator=(rc);
27 | }
28 |
29 | XYWHRect& operator=(const RECT& rc)
30 | {
31 | this->x = rc.left;
32 | this->y = rc.top;
33 | this->w = getWidth(rc);
34 | this->h = getHeight(rc);
35 |
36 | return *this;
37 | }
38 | };
39 |
40 | struct MyColor : public NVGcolor
41 | {
42 | MyColor()
43 | {
44 | }
45 |
46 | MyColor(DWORD color)
47 | {
48 | this->r = GetRValue(color) / 255.0f;
49 | this->g = GetGValue(color) / 255.0f;
50 | this->b = GetBValue(color) / 255.0f;
51 | this->a = GetAValue(color) / 255.0f;
52 | }
53 |
54 | operator DWORD()
55 | {
56 | BYTE r = (BYTE)roundf(this->r * 255.0f);
57 | BYTE g = (BYTE)roundf(this->g * 255.0f);
58 | BYTE b = (BYTE)roundf(this->b * 255.0f);
59 | BYTE a = (BYTE)roundf(this->a * 255.0f);
60 |
61 | return getDWORD(r, g, b, a);
62 | }
63 |
64 | MyColor& operator=(const NVGcolor& color)
65 | {
66 | ((NVGcolor&)*this) = color;
67 |
68 | return *this;
69 | }
70 |
71 | static BYTE GetAValue(DWORD color)
72 | {
73 | return LOBYTE(color >> 24);
74 | }
75 |
76 | static COLORREF getCOLORREF(DWORD rgba)
77 | {
78 | return (rgba & 0x00FFFFFF);
79 | }
80 |
81 | static DWORD getDWORD(BYTE r, BYTE g, BYTE b, BYTE a)
82 | {
83 | return r | ((WORD)g << 8) | ((DWORD)b << 16) | ((DWORD)a << 24);
84 | }
85 |
86 | static DWORD getDWORD(COLORREF color, DWORD rgba)
87 | {
88 | return (color & 0x00FFFFFF) | (rgba & 0xFF000000);
89 | }
90 | };
91 |
92 | struct StringU8
93 | {
94 | char m_buffer[MAX_PATH] = {};
95 |
96 | StringU8()
97 | {
98 | }
99 |
100 | StringU8(LPCWSTR x)
101 | {
102 | operator=(x);
103 | }
104 |
105 | StringU8& operator=(LPCWSTR x)
106 | {
107 | ::WideCharToMultiByte(CP_UTF8, 0, x, -1, m_buffer, MAX_PATH, 0, 0);
108 | return *this;
109 | }
110 |
111 | operator LPCSTR() const
112 | {
113 | return m_buffer;
114 | }
115 | };
116 |
117 | //--------------------------------------------------------------------
118 |
119 | struct Design
120 | {
121 | struct AlignX {
122 | static const int left = 0;
123 | static const int right = 1;
124 | static const int center = 2;
125 | static const Label labels[];
126 | };
127 |
128 | struct AlignY {
129 | static const int top = 0;
130 | static const int bottom = 1;
131 | static const int center = 2;
132 | static const Label labels[];
133 | };
134 |
135 | struct ScaleMode {
136 | static const int normal = 0;
137 | static const int fit = 1;
138 | static const int crop = 2;
139 | static const Label labels[];
140 | };
141 |
142 | struct LineStyle {
143 | static const Label labels[];
144 | };
145 |
146 | struct Fill {
147 | MyColor color;
148 | };
149 |
150 | struct GradientFill {
151 | MyColor color1;
152 | MyColor color2;
153 | };
154 |
155 | struct Stroke {
156 | int style;
157 | int width;
158 | MyColor color;
159 | };
160 |
161 | struct Text {
162 | int height;
163 | MyColor color;
164 | struct Shadow {
165 | float dilate;
166 | float blur;
167 | POINT offset;
168 | MyColor color;
169 | } shadow;
170 | };
171 |
172 | struct Marker {
173 | Stroke stroke;
174 | };
175 |
176 | _bstr_t fontDefault;
177 | _bstr_t fontDefault2;
178 | struct Image {
179 | _bstr_t fileName;
180 | POINT offset;
181 | POINT align;
182 | int scaleMode;
183 | float scale;
184 | float angle;
185 | float alpha;
186 | } image;
187 | struct Background {
188 | GradientFill fill;
189 | } background;
190 | struct Body {
191 | struct Margin {
192 | int x;
193 | int y;
194 | } margin;
195 | Stroke stroke;
196 | } body;
197 | struct Scale {
198 | struct Horz {
199 | int minUnitWidth;
200 | struct Primary {
201 | int height;
202 | Stroke stroke;
203 | Text text;
204 | } primary;
205 | struct Secondary {
206 | int height;
207 | Stroke stroke;
208 | } secondary;
209 | } horz;
210 | struct Vert {
211 | int width;
212 | Text text;
213 | Stroke stroke;
214 | struct Base {
215 | Stroke stroke;
216 | } base;
217 | } vert;
218 | } scale;
219 | struct BPM {
220 | struct Primary {
221 | Stroke stroke;
222 | Text text;
223 | } primary;
224 | struct Secondary {
225 | Stroke stroke;
226 | } secondary;
227 | } bpm;
228 | struct Graph {
229 | GradientFill fill;
230 | Stroke stroke;
231 | Marker current;
232 | Marker hot;
233 | Marker last;
234 | } graph;
235 |
236 | Design();
237 | ~Design();
238 |
239 | void load(LPCWSTR fileName);
240 | void save(LPCWSTR fileName);
241 | };
242 |
243 | extern Design g_design;
244 |
245 | //--------------------------------------------------------------------
246 |
--------------------------------------------------------------------------------
/OutProcess/MainDialog.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 | #include "MainDialog.h"
3 | #include "App.h"
4 |
5 | //--------------------------------------------------------------------
6 |
7 | BOOL MainDialog::getShowBPM()
8 | {
9 | HWND showBPM = ::GetDlgItem(*this, IDC_SHOW_BPM);
10 | return Button_GetCheck(showBPM) == BST_CHECKED;
11 | }
12 |
13 | BOOL MainDialog::setShowBPM(BOOL newShowBPM)
14 | {
15 | HWND showBPM = ::GetDlgItem(*this, IDC_SHOW_BPM);
16 | Button_SetCheck(showBPM, newShowBPM ? BST_CHECKED : BST_UNCHECKED);
17 | return TRUE;
18 | }
19 |
20 | int MainDialog::getOrig()
21 | {
22 | return ::GetDlgItemInt(*this, IDC_ORIG, 0, TRUE);
23 | }
24 |
25 | BOOL MainDialog::setOrig(int newOrig)
26 | {
27 | return ::SetDlgItemInt(*this, IDC_ORIG, newOrig, TRUE);
28 | }
29 |
30 | int MainDialog::getBPM()
31 | {
32 | return ::GetDlgItemInt(*this, IDC_BPM, 0, TRUE);
33 | }
34 |
35 | BOOL MainDialog::setBPM(int newBPM)
36 | {
37 | return ::SetDlgItemInt(*this, IDC_BPM, newBPM, TRUE);
38 | }
39 |
40 | int MainDialog::getAbove()
41 | {
42 | return ::GetDlgItemInt(*this, IDC_ABOVE, 0, TRUE);
43 | }
44 |
45 | BOOL MainDialog::setAbove(int newAbove)
46 | {
47 | return ::SetDlgItemInt(*this, IDC_ABOVE, newAbove, TRUE);
48 | }
49 |
50 | int MainDialog::getBelow()
51 | {
52 | return ::GetDlgItemInt(*this, IDC_BELOW, 0, TRUE);
53 | }
54 |
55 | BOOL MainDialog::setBelow(int newBelow)
56 | {
57 | return ::SetDlgItemInt(*this, IDC_BELOW, newBelow, TRUE);
58 | }
59 |
60 | int MainDialog::getLimitVolume()
61 | {
62 | return ::GetDlgItemInt(*this, IDC_LIMIT_VOLUME, 0, TRUE);
63 | }
64 |
65 | BOOL MainDialog::setLimitVolume(int newLimitVolume)
66 | {
67 | return ::SetDlgItemInt(*this, IDC_LIMIT_VOLUME, newLimitVolume, TRUE);
68 | }
69 |
70 | int MainDialog::getBaseVolume()
71 | {
72 | return ::GetDlgItemInt(*this, IDC_BASE_VOLUME, 0, TRUE);
73 | }
74 |
75 | BOOL MainDialog::setBaseVolume(int newBaseVolume)
76 | {
77 | return ::SetDlgItemInt(*this, IDC_BASE_VOLUME, newBaseVolume, TRUE);
78 | }
79 |
80 | int MainDialog::getMinRMS()
81 | {
82 | return ::GetDlgItemInt(*this, IDC_MIN_RMS, 0, TRUE);
83 | }
84 |
85 | BOOL MainDialog::setMinRMS(int newMinRMS)
86 | {
87 | return ::SetDlgItemInt(*this, IDC_MIN_RMS, newMinRMS, TRUE);
88 | }
89 |
90 | int MainDialog::getMaxRMS()
91 | {
92 | return ::GetDlgItemInt(*this, IDC_MAX_RMS, 0, TRUE);
93 | }
94 |
95 | BOOL MainDialog::setMaxRMS(int newMaxRMS)
96 | {
97 | return ::SetDlgItemInt(*this, IDC_MAX_RMS, newMaxRMS, TRUE);
98 | }
99 |
100 | int MainDialog::getBaseRMS()
101 | {
102 | return ::GetDlgItemInt(*this, IDC_BASE_RMS, 0, TRUE);
103 | }
104 |
105 | BOOL MainDialog::setBaseRMS(int newBaseRMS)
106 | {
107 | return ::SetDlgItemInt(*this, IDC_BASE_RMS, newBaseRMS, TRUE);
108 | }
109 |
110 | int MainDialog::getZoom()
111 | {
112 | return ::GetDlgItemInt(*this, IDC_ZOOM, 0, TRUE);
113 | }
114 |
115 | BOOL MainDialog::setZoom(int newZoom)
116 | {
117 | return ::SetDlgItemInt(*this, IDC_ZOOM, newZoom, TRUE);
118 | }
119 |
120 | //--------------------------------------------------------------------
121 |
122 | BOOL MainDialog::create(HINSTANCE instance, HWND parent)
123 | {
124 | MY_TRACE(_T("MainDialog::create()\n"));
125 |
126 | // メインダイアログを作成する。
127 |
128 | if (!Dialog::create(instance, MAKEINTRESOURCE(IDD_CONFIG_DIALOG), parent))
129 | {
130 | ::MessageBox(parent, _T("メインダイアログの作成に失敗しました"), _T("ShowWaveform"), MB_OK);
131 |
132 | return FALSE;
133 | }
134 |
135 | // コントロールを初期化する。
136 |
137 | ignoreNotification(TRUE);
138 |
139 | setShowBPM(theApp.getShowBPM());
140 | setOrig(theApp.getOrig());
141 | setBPM(theApp.getBPM());
142 | setAbove(theApp.getAbove());
143 | setBelow(theApp.getBelow());
144 |
145 | setLimitVolume(theApp.getLimitVolume());
146 | setBaseVolume(theApp.getBaseVolume());
147 | setMinRMS(theApp.getMinRMS());
148 | setMaxRMS(theApp.getMaxRMS());
149 | setBaseRMS(theApp.getBaseRMS());
150 | setZoom(theApp.getZoom());
151 |
152 | ignoreNotification(FALSE);
153 |
154 | return TRUE;
155 | }
156 |
157 | void MainDialog::ignoreNotification(BOOL ignoreNotification)
158 | {
159 | m_ignoreNotification = ignoreNotification;
160 | }
161 |
162 | INT_PTR MainDialog::onDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
163 | {
164 | switch (message)
165 | {
166 | case WM_COMMAND:
167 | {
168 | MY_TRACE(_T("MainDialog::onDlgProc(WM_COMMAND, 0x%08X, 0x%08X)\n"), wParam, lParam);
169 |
170 | // App のセッターを使用するとダイアログが再更新されてしまうので
171 | // メインウィンドウのセッターを使用する。
172 |
173 | UINT code = HIWORD(wParam);
174 | UINT id = LOWORD(wParam);
175 | HWND sender = (HWND)lParam;
176 |
177 | switch (id)
178 | {
179 | case IDC_SHOW_BPM:
180 | {
181 | theApp.mainWindow.setShowBPM(getShowBPM());
182 |
183 | break;
184 | }
185 | case IDC_ORIG:
186 | {
187 | if (code == EN_UPDATE && !m_ignoreNotification)
188 | theApp.mainWindow.setOrig(getOrig());
189 |
190 | break;
191 | }
192 | case IDC_BPM:
193 | {
194 | if (code == EN_UPDATE && !m_ignoreNotification)
195 | theApp.mainWindow.setBPM(getBPM());
196 |
197 | break;
198 | }
199 | case IDC_ABOVE:
200 | {
201 | if (code == EN_UPDATE && !m_ignoreNotification)
202 | theApp.mainWindow.setAbove(getAbove());
203 |
204 | break;
205 | }
206 | case IDC_BELOW:
207 | {
208 | if (code == EN_UPDATE && !m_ignoreNotification)
209 | theApp.mainWindow.setBelow(getBelow());
210 |
211 | break;
212 | }
213 | case IDC_LIMIT_VOLUME:
214 | {
215 | if (code == EN_UPDATE && !m_ignoreNotification)
216 | theApp.mainWindow.setLimitVolume(getLimitVolume());
217 |
218 | break;
219 | }
220 | case IDC_BASE_VOLUME:
221 | {
222 | if (code == EN_UPDATE && !m_ignoreNotification)
223 | theApp.mainWindow.setBaseVolume(getBaseVolume());
224 |
225 | break;
226 | }
227 | case IDC_MIN_RMS:
228 | {
229 | if (code == EN_UPDATE && !m_ignoreNotification)
230 | theApp.mainWindow.setMinRMS(getMinRMS());
231 |
232 | break;
233 | }
234 | case IDC_MAX_RMS:
235 | {
236 | if (code == EN_UPDATE && !m_ignoreNotification)
237 | theApp.mainWindow.setMaxRMS(getMaxRMS());
238 |
239 | break;
240 | }
241 | case IDC_BASE_RMS:
242 | {
243 | if (code == EN_UPDATE && !m_ignoreNotification)
244 | theApp.mainWindow.setBaseRMS(getBaseRMS());
245 |
246 | break;
247 | }
248 | case IDC_ZOOM:
249 | {
250 | if (code == EN_UPDATE && !m_ignoreNotification)
251 | theApp.mainWindow.setZoom(getZoom());
252 |
253 | break;
254 | }
255 | }
256 |
257 | break;
258 | }
259 | case WM_NOTIFY:
260 | {
261 | MY_TRACE(_T("MainDialog::onDlgProc(WM_NOTIFY, 0x%08X, 0x%08X)\n"), wParam, lParam);
262 |
263 | NMHDR* header = (NMHDR*)lParam;
264 | if (header->code == UDN_DELTAPOS)
265 | {
266 | int value = ::GetDlgItemInt(hwnd, header->idFrom - 1, 0, TRUE);
267 |
268 | NM_UPDOWN* nm = (NM_UPDOWN*)header;
269 | if (nm->iDelta < 0)
270 | {
271 | value += 1;
272 | }
273 | else
274 | {
275 | value -= 1;
276 | }
277 |
278 | ::SetDlgItemInt(hwnd, header->idFrom - 1, value, TRUE);
279 | }
280 |
281 | break;
282 | }
283 | }
284 |
285 | if (message == WM_AVIUTL_FILTER_RESIZE) return onAviUtlFilterResize(hwnd, message, wParam, lParam);
286 |
287 | return Dialog::onDlgProc(hwnd, message, wParam, lParam);
288 | }
289 |
290 | LRESULT MainDialog::onAviUtlFilterResize(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
291 | {
292 | MY_TRACE(_T("onAviUtlFilterResize(0x%08X, 0x%08X)\n"), wParam, lParam);
293 |
294 | HWND parent = ::GetParent(hwnd);
295 | RECT rc; ::GetClientRect(parent, &rc);
296 | MY_TRACE_RECT2(rc);
297 | ::SetWindowPos(hwnd, 0, rc.left, rc.top, getWidth(rc), getHeight(rc), SWP_NOZORDER);
298 |
299 | return 0;
300 | }
301 |
302 | //--------------------------------------------------------------------
303 |
--------------------------------------------------------------------------------
/OutProcess/MainDialog.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "Resource.h"
3 |
4 | struct MainDialog : public Tools::Dialog
5 | {
6 | BOOL m_ignoreNotification = FALSE;
7 |
8 | BOOL getShowBPM();
9 | BOOL setShowBPM(BOOL newShowBPM);
10 | int getOrig();
11 | BOOL setOrig(int newOrig);
12 | int getBPM();
13 | BOOL setBPM(int newBPM);
14 | int getAbove();
15 | BOOL setAbove(int newAbove);
16 | int getBelow();
17 | BOOL setBelow(int newBelow);
18 |
19 | int getLimitVolume();
20 | BOOL setLimitVolume(int newLimitVolume);
21 | int getBaseVolume();
22 | BOOL setBaseVolume(int newBaseVolume);
23 | int getMinRMS();
24 | BOOL setMinRMS(int newMinRMS);
25 | int getMaxRMS();
26 | BOOL setMaxRMS(int newMaxRMS);
27 | int getBaseRMS();
28 | BOOL setBaseRMS(int newBaseRMS);
29 | int getZoom();
30 | BOOL setZoom(int newZoom);
31 |
32 | BOOL create(HINSTANCE instance, HWND parent);
33 | void ignoreNotification(BOOL ignoreNotification);
34 | virtual INT_PTR onDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
35 | LRESULT onAviUtlFilterResize(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
36 | };
37 |
--------------------------------------------------------------------------------
/OutProcess/MainWindow.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "OutProcess.h"
4 | #include "Design.h"
5 | #include "Mode.h"
6 |
7 | //--------------------------------------------------------------------
8 |
9 | struct MakeCurrent
10 | {
11 | HDC m_prevDC = 0;
12 | HGLRC m_prevRC = 0;
13 |
14 | MakeCurrent(HDC dc, HGLRC rc)
15 | {
16 | m_prevDC = wglGetCurrentDC();
17 | m_prevRC = wglGetCurrentContext();
18 |
19 | wglMakeCurrent(dc, rc);
20 | }
21 |
22 | ~MakeCurrent()
23 | {
24 | wglMakeCurrent(m_prevDC, m_prevRC);
25 | }
26 | };
27 |
28 | struct LayoutContext {
29 | RECT rc;
30 | int x, y, w, h;
31 | int hScroll;
32 | struct Graph {
33 | int x, y, w, h;
34 | int left, right, top, bottom;
35 | } graph;
36 | int padding;
37 | double zoomScale;
38 | };
39 |
40 | //--------------------------------------------------------------------
41 |
42 | struct MainWindow
43 | {
44 | struct CommandID {
45 | struct Mode {
46 | static const UINT rms = 1000;
47 | static const UINT center = 1001;
48 | static const UINT bottomUp = 1002;
49 | static const UINT topDown = 1003;
50 | };
51 | struct HorzScale {
52 | struct VisibleStyle {
53 | static const UINT both = 2000;
54 | static const UINT top = 2001;
55 | static const UINT bottom = 2002;
56 | };
57 | struct LineStyle {
58 | static const UINT side = 2100;
59 | static const UINT straight = 2101;
60 | };
61 | };
62 | struct VertScale {
63 | struct VisibleStyle {
64 | static const UINT both = 3000;
65 | static const UINT left = 3001;
66 | static const UINT right = 3002;
67 | };
68 | struct LineStyle {
69 | static const UINT side = 3100;
70 | static const UINT straight = 3101;
71 | };
72 | };
73 | static const UINT showMainDialog = 4000;
74 | };
75 |
76 | struct TimerID {
77 | static const UINT checkConfig = 1000;
78 | };
79 |
80 | struct Mode {
81 | static const int rms = 0;
82 | static const int center = 1;
83 | static const int bottomUp = 2;
84 | static const int topDown = 3;
85 | static const Label labels[];
86 | };
87 |
88 | struct HorzScaleSettings {
89 | struct VisibleStyle {
90 | static const int both = 0;
91 | static const int top = 1;
92 | static const int bottom = 2;
93 | static const Label labels[];
94 | };
95 | struct LineStyle {
96 | static const int side = 0;
97 | static const int straight = 1;
98 | static const Label labels[];
99 | };
100 | int visibleStyle;
101 | int lineStyle;
102 | };
103 |
104 | struct VertScaleSettings {
105 | struct VisibleStyle {
106 | static const int both = 0;
107 | static const int left = 1;
108 | static const int right = 2;
109 | static const Label labels[];
110 | };
111 | struct LineStyle {
112 | static const int side = 0;
113 | static const int straight = 1;
114 | static const Label labels[];
115 | };
116 | int visibleStyle;
117 | int lineStyle;
118 | };
119 |
120 | struct HitTest {
121 | static const int None = 0;
122 | static const int HorzScale = 1;
123 | static const int VertScaleMin = 2;
124 | static const int VertScaleMax = 3;
125 | };
126 |
127 | int m_limitVolume = 100;
128 | int m_baseVolume = 50;
129 | int m_minRMS = -33;
130 | int m_maxRMS = 14;
131 | int m_baseRMS = 0;
132 | int m_zoom = 0; // グラフの論理幅を増加させる。
133 | HorzScaleSettings m_horzScaleSettings = {
134 | HorzScaleSettings::VisibleStyle::both,
135 | HorzScaleSettings::LineStyle::side,
136 | };
137 | VertScaleSettings m_vertScaleSettings = {
138 | VertScaleSettings::VisibleStyle::both,
139 | VertScaleSettings::LineStyle::straight,
140 | };
141 | TotalsParams m_totalsParams;
142 | ModePtr m_mode = std::make_shared();
143 |
144 | int m_hotFrame = 0;
145 | struct Drag {
146 | int ht = HitTest::None;
147 | POINT origPoint = {};
148 | int origValue = 0;
149 | } drag;
150 |
151 | BOOL getShowBPM();
152 | BOOL setShowBPM(BOOL newShowBPM);
153 | int getOrig();
154 | BOOL setOrig(int newOrig);
155 | int getBPM();
156 | BOOL setBPM(int newBPM);
157 | int getAbove();
158 | BOOL setAbove(int newAbove);
159 | int getBelow();
160 | BOOL setBelow(int newBelow);
161 |
162 | int getLimitVolume();
163 | BOOL setLimitVolume(int newLimitVolume);
164 | int getBaseVolume();
165 | BOOL setBaseVolume(int newBaseVolume);
166 | int getMinRMS();
167 | BOOL setMinRMS(int newMinRMS);
168 | int getMaxRMS();
169 | BOOL setMaxRMS(int newMaxRMS);
170 | int getBaseRMS();
171 | BOOL setBaseRMS(int newBaseRMS);
172 | int getZoom();
173 | BOOL setZoom(int newZoom);
174 | ModePtr getMode();
175 | int getHotFrame();
176 | BOOL setHotFrame(int newHotFrame);
177 | BOOL updateShared();
178 |
179 | // Layout
180 |
181 | double getZoomScale();
182 | BOOL getLayoutContext(LayoutContext& context);
183 | BOOL getLayoutContext(LayoutContext& context, const RECT& rc);
184 | void recalcLayout();
185 | int hitTest(POINT point);
186 | int client2frame(int x);
187 | int client2frame(const LayoutContext& context, int x);
188 | int frame2client(int frame);
189 | int frame2client(const LayoutContext& context, int frame);
190 | int sec2frame(double sec);
191 | double frame2sec(int frame);
192 | static int sec2px(double zoomScale, double sec);
193 | static double px2sec(double zoomScale, int px);
194 | static double getUnitSec(double zoomScale);
195 | void outputFrames();
196 |
197 | // Config
198 |
199 | FileUpdateCheckerPtr m_configFileChecker;
200 | BOOL initConfig();
201 | BOOL termConfig();
202 | void reloadConfig();
203 | void recalcConfig();
204 | void recalcConfigInternal();
205 | LRESULT onTimerCheckConfig(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
206 | void load(LPCWSTR fileName);
207 | void save(LPCWSTR fileName);
208 |
209 | // OpenGL & NanoVG
210 |
211 | HGLRC m_rc = 0;
212 | NVGcontext* m_vg = 0;
213 | int m_fontDefault = 0;
214 | int m_fontDefault2 = 0;
215 | int m_image = 0;
216 | static BOOL setupPixelFormat(HDC dc);
217 | BOOL initOpenGL();
218 | BOOL termOpenGL();
219 | void doPaint(HDC dc, const RECT& rc);
220 | void doPaint(const RECT& rc);
221 |
222 | // Window
223 |
224 | HWND m_hwnd = 0;
225 | operator HWND() const { return m_hwnd; }
226 | void redraw();
227 | BOOL create(HINSTANCE instance, HWND parent);
228 | LRESULT onCreate(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
229 | LRESULT onDestroy(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
230 | LRESULT onSize(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
231 | LRESULT onHScroll(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
232 | LRESULT onTimer(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
233 | LRESULT onPaint(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
234 | LRESULT onContextMenu(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
235 | LRESULT onSetCursor(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
236 | LRESULT onMouseMove(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
237 | LRESULT onMouseWheel(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
238 | LRESULT onLButtonDown(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
239 | LRESULT onLButtonUp(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
240 | LRESULT onAviUtlFilterExit(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
241 | LRESULT onAviUtlFilterResize(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
242 | static LRESULT CALLBACK wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
243 | };
244 |
245 | //--------------------------------------------------------------------
246 |
--------------------------------------------------------------------------------
/OutProcess/MainWindow_Config.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 | #include "MainWindow.h"
3 | #include "App.h"
4 |
5 | //--------------------------------------------------------------------
6 |
7 | const Label MainWindow::HorzScaleSettings::VisibleStyle::labels[] = {
8 | { both, L"both" },
9 | { top, L"top" },
10 | { bottom, L"bottom" },
11 | };
12 |
13 | const Label MainWindow::HorzScaleSettings::LineStyle::labels[] = {
14 | { side, L"side" },
15 | { straight, L"straight" },
16 | };
17 |
18 | const Label MainWindow::VertScaleSettings::VisibleStyle::labels[] = {
19 | { both, L"both" },
20 | { left, L"left" },
21 | { right, L"right" },
22 | };
23 |
24 | const Label MainWindow::VertScaleSettings::LineStyle::labels[] = {
25 | { side, L"side" },
26 | { straight, L"straight" },
27 | };
28 |
29 | const Label MainWindow::Mode::labels[] = {
30 | { rms, L"rms" },
31 | { center, L"center" },
32 | { bottomUp, L"bottomUp" },
33 | { topDown, L"topDown" },
34 | };
35 |
36 | //--------------------------------------------------------------------
37 |
38 | BOOL MainWindow::initConfig()
39 | {
40 | MY_TRACE(_T("MainWindow::initConfig()\n"));
41 |
42 | WCHAR fileName[MAX_PATH] = {};
43 | ::GetModuleFileNameW(theApp.instance, fileName, MAX_PATH);
44 | ::PathRemoveFileSpecW(fileName);
45 | ::PathAppendW(fileName, _T("Config.ini"));
46 | MY_TRACE_WSTR(fileName);
47 |
48 | m_configFileChecker = std::make_shared(fileName);
49 | ::SetTimer(m_hwnd, TimerID::checkConfig, 1000, 0); // 1 秒に 1 回コンフィグファイルをチェックする。
50 | reloadConfig();
51 |
52 | return TRUE;
53 | }
54 |
55 | BOOL MainWindow::termConfig()
56 | {
57 | MY_TRACE(_T("MainWindow::termConfig()\n"));
58 |
59 | ::KillTimer(m_hwnd, TimerID::checkConfig);
60 |
61 | save(m_configFileChecker->getFilePath());
62 |
63 | return TRUE;
64 | }
65 |
66 | void MainWindow::reloadConfig()
67 | {
68 | MY_TRACE(_T("MainWindow::reloadConfig()\n"));
69 |
70 | load(m_configFileChecker->getFilePath());
71 |
72 | recalcConfig();
73 | }
74 |
75 | void MainWindow::recalcConfig()
76 | {
77 | MY_TRACE(_T("MainWindow::recalcConfig()\n"));
78 |
79 | ClientDC dc(m_hwnd);
80 | MakeCurrent makeCurrent(dc, m_rc);
81 |
82 | recalcConfigInternal();
83 | }
84 |
85 | void MainWindow::recalcConfigInternal()
86 | {
87 | MY_TRACE(_T("MainWindow::recalcConfigInternal()\n"));
88 |
89 | MY_TRACE_WSTR((BSTR)g_design.fontDefault);
90 | m_fontDefault = nvgCreateFont(m_vg, "default", StringU8(g_design.fontDefault));
91 | MY_TRACE_INT(m_fontDefault);
92 |
93 | MY_TRACE_WSTR((BSTR)g_design.fontDefault2);
94 | m_fontDefault2 = nvgCreateFont(m_vg, "default2", StringU8(g_design.fontDefault2));
95 | MY_TRACE_INT(m_fontDefault2);
96 |
97 | nvgAddFallbackFontId(m_vg, m_fontDefault, m_fontDefault2);
98 |
99 | if (m_image) nvgDeleteImage(m_vg, m_image);
100 | m_image = nvgCreateImage(m_vg, g_design.image.fileName, NVG_IMAGE_NEAREST);
101 | MY_TRACE_INT(m_image);
102 | }
103 |
104 | LRESULT MainWindow::onTimerCheckConfig(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
105 | {
106 | if (m_configFileChecker->isFileUpdated())
107 | {
108 | reloadConfig();
109 | redraw();
110 | }
111 |
112 | return 0;
113 | }
114 |
115 | void MainWindow::load(LPCWSTR fileName)
116 | {
117 | MY_TRACE(_T("MainWindow::load(%ws)\n"), fileName);
118 |
119 | int mode = m_mode->getID();
120 |
121 | getPrivateProfileInt(fileName, L"Config", L"maxReaderCount", theApp.readerManager.maxReaderCount);
122 | getPrivateProfileInt(fileName, L"Config", L"limitVolume", m_limitVolume);
123 | getPrivateProfileInt(fileName, L"Config", L"baseVolume", m_baseVolume);
124 | getPrivateProfileInt(fileName, L"Config", L"minRMS", m_minRMS);
125 | getPrivateProfileInt(fileName, L"Config", L"maxRMS", m_maxRMS);
126 | getPrivateProfileInt(fileName, L"Config", L"baseRMS", m_baseRMS);
127 | getPrivateProfileInt(fileName, L"Config", L"zoom", m_zoom);
128 | getPrivateProfileLabel(fileName, L"Config", L"mode", mode, Mode::labels);
129 | getPrivateProfileLabel(fileName, L"Config", L"horzScaleSettings.visibleStyle", m_horzScaleSettings.visibleStyle, HorzScaleSettings::VisibleStyle::labels);
130 | getPrivateProfileLabel(fileName, L"Config", L"horzScaleSettings.lineStyle", m_horzScaleSettings.lineStyle, HorzScaleSettings::LineStyle::labels);
131 | getPrivateProfileLabel(fileName, L"Config", L"vertScaleSettings.visibleStyle", m_vertScaleSettings.visibleStyle, VertScaleSettings::VisibleStyle::labels);
132 | getPrivateProfileLabel(fileName, L"Config", L"vertScaleSettings.lineStyle", m_vertScaleSettings.lineStyle, VertScaleSettings::LineStyle::labels);
133 |
134 | switch (mode)
135 | {
136 | case Mode::rms: m_mode = std::make_shared(); break;
137 | case Mode::center: m_mode = std::make_shared(); break;
138 | case Mode::bottomUp: m_mode = std::make_shared(); break;
139 | case Mode::topDown: m_mode = std::make_shared(); break;
140 | }
141 |
142 | g_design.load(fileName);
143 | }
144 |
145 | void MainWindow::save(LPCWSTR fileName)
146 | {
147 | MY_TRACE(_T("MainWindow::save(%ws)\n"), fileName);
148 |
149 | int mode = m_mode->getID();
150 |
151 | setPrivateProfileInt(fileName, L"Config", L"maxReaderCount", theApp.readerManager.maxReaderCount);
152 | setPrivateProfileInt(fileName, L"Config", L"limitVolume", m_limitVolume);
153 | setPrivateProfileInt(fileName, L"Config", L"baseVolume", m_baseVolume);
154 | setPrivateProfileInt(fileName, L"Config", L"minRMS", m_minRMS);
155 | setPrivateProfileInt(fileName, L"Config", L"maxRMS", m_maxRMS);
156 | setPrivateProfileInt(fileName, L"Config", L"baseRMS", m_baseRMS);
157 | setPrivateProfileInt(fileName, L"Config", L"zoom", m_zoom);
158 | setPrivateProfileLabel(fileName, L"Config", L"mode", mode, Mode::labels);
159 | setPrivateProfileLabel(fileName, L"Config", L"horzScaleSettings.visibleStyle", m_horzScaleSettings.visibleStyle, HorzScaleSettings::VisibleStyle::labels);
160 | setPrivateProfileLabel(fileName, L"Config", L"horzScaleSettings.lineStyle", m_horzScaleSettings.lineStyle, HorzScaleSettings::LineStyle::labels);
161 | setPrivateProfileLabel(fileName, L"Config", L"vertScaleSettings.visibleStyle", m_vertScaleSettings.visibleStyle, VertScaleSettings::VisibleStyle::labels);
162 | setPrivateProfileLabel(fileName, L"Config", L"vertScaleSettings.lineStyle", m_vertScaleSettings.lineStyle, VertScaleSettings::LineStyle::labels);
163 |
164 | g_design.save(fileName);
165 | }
166 |
167 | //--------------------------------------------------------------------
168 |
--------------------------------------------------------------------------------
/OutProcess/MainWindow_Layout.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 | #include "MainWindow.h"
3 | #include "App.h"
4 |
5 | //--------------------------------------------------------------------
6 |
7 | /*
8 | ズーム値からズーム倍率を計算して返す。
9 |
10 | ズーム値は px 単位で、マイナスになることもあるが、
11 | ズーム倍率は 0.0 より大きい数値になる。
12 | */
13 | double MainWindow::getZoomScale()
14 | {
15 | return std::pow(2.0, (double)m_zoom / g_design.scale.horz.minUnitWidth);
16 | }
17 |
18 | BOOL MainWindow::getLayoutContext(LayoutContext& context)
19 | {
20 | RECT rc; ::GetClientRect(m_hwnd, &rc);
21 | return getLayoutContext(context, rc);
22 | }
23 |
24 | BOOL MainWindow::getLayoutContext(LayoutContext& context, const RECT& rc)
25 | {
26 | context.rc = rc;
27 | context.x = rc.left;
28 | context.y = rc.top;
29 | context.w = getWidth(rc);
30 | context.h = getHeight(rc);
31 |
32 | if (context.w <= 0 || context.h <= 0) return FALSE;
33 |
34 | context.hScroll = ::GetScrollPos(m_hwnd, SB_HORZ);
35 |
36 | switch (m_vertScaleSettings.visibleStyle)
37 | {
38 | case VertScaleSettings::VisibleStyle::left:
39 | {
40 | context.graph.x = (int)(context.x + g_design.body.margin.x);
41 | context.graph.w = (int)(context.w - g_design.body.margin.x);
42 | break;
43 | }
44 | case VertScaleSettings::VisibleStyle::right:
45 | {
46 | context.graph.x = (int)(context.x);
47 | context.graph.w = (int)(context.w - g_design.body.margin.x);
48 | break;
49 | }
50 | case VertScaleSettings::VisibleStyle::both:
51 | {
52 | context.graph.x = (int)(context.x + g_design.body.margin.x);
53 | context.graph.w = (int)(context.w - g_design.body.margin.x * 2);
54 | break;
55 | }
56 | }
57 |
58 | switch (m_horzScaleSettings.visibleStyle)
59 | {
60 | case HorzScaleSettings::VisibleStyle::top:
61 | {
62 | context.graph.y = (int)(context.y + g_design.body.margin.y);
63 | context.graph.h = (int)(context.h - g_design.body.margin.y);
64 | break;
65 | }
66 | case HorzScaleSettings::VisibleStyle::bottom:
67 | {
68 | context.graph.y = (int)(context.y);
69 | context.graph.h = (int)(context.h - g_design.body.margin.y);
70 | break;
71 | }
72 | case HorzScaleSettings::VisibleStyle::both:
73 | {
74 | context.graph.y = (int)(context.y + g_design.body.margin.y);
75 | context.graph.h = (int)(context.h - g_design.body.margin.y * 2);
76 | break;
77 | }
78 | }
79 |
80 | context.graph.left = context.graph.x;
81 | context.graph.right = context.graph.x + context.graph.w;
82 | context.graph.top = context.graph.y;
83 | context.graph.bottom = context.graph.y + context.graph.h;
84 | context.padding = 10;
85 |
86 | if (context.graph.w <= 0 || context.graph.h <= 0) return FALSE;
87 |
88 | context.zoomScale = getZoomScale();
89 |
90 | return TRUE;
91 | }
92 |
93 | //--------------------------------------------------------------------
94 |
95 | void MainWindow::recalcLayout()
96 | {
97 | MY_TRACE(_T("MainWindow::recalcLayout()\n"));
98 |
99 | int c = (int)theApp.totals.size();
100 | if (c <= 1) return;
101 |
102 | LayoutContext context = {};
103 | if (!getLayoutContext(context)) return;
104 |
105 | double sec = frame2sec(c - 1);
106 | int logicalWidth = sec2px(context.zoomScale, sec);
107 |
108 | SCROLLINFO si = { sizeof(si) };
109 | si.fMask = SIF_POS | SIF_RANGE | SIF_PAGE;
110 | ::GetScrollInfo(m_hwnd, SB_HORZ, &si);
111 |
112 | double pos = 0.0;
113 | int div = si.nMax - std::max((int)si.nPage - 1, 0);
114 | if (div)
115 | pos = (double)si.nPos / div;
116 |
117 | si.nPos = (int)(pos * (logicalWidth - context.graph.w));
118 | si.nMin = 0;
119 | si.nMax = logicalWidth;
120 | si.nPage = context.graph.w + 1;
121 | ::SetScrollInfo(m_hwnd, SB_HORZ, &si, TRUE);
122 | }
123 |
124 | int MainWindow::hitTest(POINT point)
125 | {
126 | RECT rc; ::GetClientRect(*this, &rc);
127 | int cy = getCenterY(rc);
128 |
129 | if (m_horzScaleSettings.visibleStyle != HorzScaleSettings::VisibleStyle::bottom)
130 | {
131 | if (point.y < rc.top + g_design.body.margin.y)
132 | return HitTest::HorzScale;
133 | }
134 |
135 | if (m_horzScaleSettings.visibleStyle != HorzScaleSettings::VisibleStyle::top)
136 | {
137 | if (point.y > rc.bottom - g_design.body.margin.y)
138 | return HitTest::HorzScale;
139 | }
140 |
141 | if (m_vertScaleSettings.visibleStyle != VertScaleSettings::VisibleStyle::right)
142 | {
143 | if (point.x < rc.left + g_design.body.margin.x)
144 | return (point.y > cy) ? HitTest::VertScaleMin : HitTest::VertScaleMax;
145 | }
146 |
147 | if (m_vertScaleSettings.visibleStyle != VertScaleSettings::VisibleStyle::left)
148 | {
149 | if (point.x > rc.right - g_design.body.margin.x)
150 | return (point.y > cy) ? HitTest::VertScaleMin : HitTest::VertScaleMax;
151 | }
152 |
153 | return HitTest::None;
154 | }
155 |
156 | int MainWindow::client2frame(int x)
157 | {
158 | LayoutContext context = {};
159 | if (!getLayoutContext(context)) return 0;
160 |
161 | return client2frame(context, x);
162 | }
163 |
164 | /*
165 | クライアント座標の x からフレーム番号を取得する。
166 | ・グラフの X 座標が影響する。
167 | ・水平スクロールが影響する。
168 | */
169 | int MainWindow::client2frame(const LayoutContext& context, int x)
170 | {
171 | double sec = px2sec(context.zoomScale, x + context.hScroll - context.graph.x);
172 | return sec2frame(sec);
173 | }
174 |
175 | int MainWindow::frame2client(int frame)
176 | {
177 | LayoutContext context = {};
178 | if (!getLayoutContext(context)) return 0;
179 |
180 | return frame2client(context, frame);
181 | }
182 |
183 | /*
184 | フレーム番号からクライアント座標を取得する。
185 | ・グラフの X 座標が影響する。
186 | ・水平スクロールが影響する。
187 | */
188 | int MainWindow::frame2client(const LayoutContext& context, int frame)
189 | {
190 | double sec = frame2sec(frame);
191 | return sec2px(context.zoomScale, sec) - context.hScroll + context.graph.x;
192 | }
193 |
194 | int MainWindow::sec2frame(double sec)
195 | {
196 | if (!theApp.projectParams) return 0;
197 |
198 | int video_rate = theApp.projectParams->video_rate;
199 | int video_scale = theApp.projectParams->video_scale;
200 |
201 | if (video_rate == 0 || video_scale == 0)
202 | return 0;
203 |
204 | return (int)(sec * video_rate / video_scale);
205 | }
206 |
207 | double MainWindow::frame2sec(int frame)
208 | {
209 | if (!theApp.projectParams) return 0;
210 |
211 | int video_rate = theApp.projectParams->video_rate;
212 | int video_scale = theApp.projectParams->video_scale;
213 |
214 | if (video_rate == 0 || video_scale == 0)
215 | return 0;
216 |
217 | return (double)frame * video_scale / video_rate;
218 | }
219 |
220 | int MainWindow::sec2px(double zoomScale, double sec)
221 | {
222 | return (int)(sec * g_design.scale.horz.minUnitWidth * zoomScale);
223 | }
224 |
225 | double MainWindow::px2sec(double zoomScale, int px)
226 | {
227 | return (double)px / g_design.scale.horz.minUnitWidth / zoomScale;
228 | }
229 |
230 | double MainWindow::getUnitSec(double zoomScale)
231 | {
232 | double secMinWidth = px2sec(zoomScale, g_design.scale.horz.minUnitWidth);
233 | double sec = 1.0;
234 |
235 | if (zoomScale > 1.0)
236 | {
237 | // 単位秒は 1 より小さい。
238 |
239 | while (1)
240 | {
241 | const double list[] =
242 | {
243 | 2.0,
244 | 3.0,
245 | 4.0,
246 | 5.0,
247 | 10.0,
248 | };
249 |
250 | double prev = sec;
251 |
252 | for (int i = 0; i < _countof(list); i++)
253 | {
254 | double temp = sec / list[i];
255 |
256 | if (temp < secMinWidth)
257 | return prev;
258 |
259 | prev = temp;
260 | }
261 |
262 | sec /= 10.0;
263 | }
264 | }
265 | else
266 | {
267 | // 単位秒は 1 より大きい。
268 |
269 | while (1)
270 | {
271 | const double list[] =
272 | {
273 | 1.0,
274 | 2.0,
275 | 3.0,
276 | 4.0,
277 | 5.0,
278 | 6.0,
279 | };
280 |
281 | for (int i = 0; i < _countof(list); i++)
282 | {
283 | double temp = sec * list[i];
284 |
285 | if (temp >= secMinWidth)
286 | return temp;
287 | }
288 |
289 | sec *= 10.0;
290 | }
291 | }
292 |
293 | return sec;
294 | }
295 |
296 | //--------------------------------------------------------------------
297 |
298 | void MainWindow::outputFrames()
299 | {
300 | MY_TRACE(_T("outputFrames()\n"));
301 |
302 | if (!theApp.projectParams) return;
303 |
304 | TCHAR text[1024] = {};
305 |
306 | int c = (int)theApp.totals.size();
307 | int currentFrame = theApp.projectParams->currentFrame;
308 | int hotFrame = getHotFrame();
309 |
310 | if (currentFrame >= 0 && currentFrame < c)
311 | {
312 | FormatText subText(_T("現在位置 : %.2fdB @%d\r\n"), theApp.totals[currentFrame].rms, currentFrame);
313 | ::StringCbCat(text, sizeof(text), subText);
314 | }
315 |
316 | if (hotFrame >= 0 && hotFrame < c)
317 | {
318 | FormatText subText(_T("マウス位置 : %.2fdB @%d\r\n"), theApp.totals[hotFrame].rms, hotFrame);
319 | ::StringCbCat(text, sizeof(text), subText);
320 | }
321 |
322 | ::SetDlgItemText(theApp.mainDialog, IDC_STATUS, text);
323 | }
324 |
325 | //--------------------------------------------------------------------
326 |
327 | LRESULT MainWindow::onSize(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
328 | {
329 | MY_TRACE(_T("MainWindow::onSize(0x%08X, 0x%08X)\n"), wParam, lParam);
330 |
331 | recalcLayout();
332 |
333 | return ::DefWindowProc(hwnd, message, wParam, lParam);
334 | }
335 |
336 | LRESULT MainWindow::onHScroll(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
337 | {
338 | UINT sb = LOWORD(wParam);
339 | // int thumbPos = HIWORD(wParam);
340 | HWND scrollBar = (HWND)lParam;
341 |
342 | SCROLLINFO si = { sizeof(si) };
343 | si.fMask = SIF_POS | SIF_RANGE | SIF_PAGE | SIF_TRACKPOS;
344 | ::GetScrollInfo(hwnd, SB_HORZ, &si);
345 |
346 | MY_TRACE(_T("MainWindow::onHScroll(%d, %d, 0x%08X)\n"), sb, si.nTrackPos, scrollBar);
347 |
348 | int pos = si.nPos;
349 |
350 | switch (sb)
351 | {
352 | case SB_LEFT: pos = si.nMin; break;
353 | case SB_RIGHT: pos = si.nMax; break;
354 | case SB_LINELEFT: pos = si.nPos - 1; break;
355 | case SB_LINERIGHT: pos = si.nPos + 1; break;
356 | case SB_PAGELEFT: pos = si.nPos - 100; break;
357 | case SB_PAGERIGHT: pos = si.nPos + 100; break;
358 | case SB_THUMBPOSITION:
359 | case SB_THUMBTRACK: pos = si.nTrackPos; break;
360 | }
361 |
362 | int min = 0;
363 | int max = si.nMax - std::max(si.nPage - 1, 0);
364 |
365 | pos = std::max(pos, min);
366 | pos = std::min(pos, max);
367 |
368 | if (si.nPos != pos)
369 | {
370 | si.nPos = pos;
371 | ::SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
372 | ::InvalidateRect(hwnd, 0, FALSE);
373 |
374 | return TRUE;
375 | }
376 |
377 | return ::DefWindowProc(hwnd, message, wParam, lParam);
378 | }
379 |
380 | //--------------------------------------------------------------------
381 |
--------------------------------------------------------------------------------
/OutProcess/MainWindow_Mouse.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 | #include "MainWindow.h"
3 | #include "App.h"
4 |
5 | //--------------------------------------------------------------------
6 |
7 | LRESULT MainWindow::onSetCursor(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
8 | {
9 | // MY_TRACE(_T("MainWindow::onSetCursor(0x%08X, 0x%08X)\n"), wParam, lParam);
10 |
11 | HWND cursorHolder = (HWND)wParam;
12 |
13 | if (cursorHolder == hwnd && LOWORD(lParam) == HTCLIENT)
14 | {
15 | POINT point; ::GetCursorPos(&point);
16 | ::MapWindowPoints(0, hwnd, &point, 1);
17 |
18 | int ht = hitTest(point);
19 |
20 | switch (ht)
21 | {
22 | case HitTest::HorzScale: ::SetCursor(::LoadCursor(0, IDC_SIZEWE)); return TRUE;
23 | case HitTest::VertScaleMin:
24 | case HitTest::VertScaleMax: ::SetCursor(::LoadCursor(0, IDC_SIZENS)); return TRUE;
25 | }
26 | }
27 |
28 | return ::DefWindowProc(hwnd, message, wParam, lParam);
29 | }
30 |
31 | LRESULT MainWindow::onMouseMove(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
32 | {
33 | // MY_TRACE(_T("MainWindow::onMouseMove(0x%08X, 0x%08X)\n"), wParam, lParam);
34 |
35 | POINT point = LP2PT(lParam);
36 |
37 | if (::GetCapture() == hwnd)
38 | {
39 | // ※ダイアログも更新しないといけないので App のセッターを使用する。
40 |
41 | switch (drag.ht)
42 | {
43 | case MainWindow::HitTest::HorzScale:
44 | {
45 | // zoom をドラッグして変更する。
46 |
47 | int offset = point.x - drag.origPoint.x;
48 |
49 | theApp.setZoom(drag.origValue + offset);
50 |
51 | break;
52 | }
53 | case MainWindow::HitTest::VertScaleMin:
54 | case MainWindow::HitTest::VertScaleMax:
55 | {
56 | // minRMS, maxRMS, limitVolume をドラッグして変更する。
57 |
58 | int offset = (point.y - drag.origPoint.y) / 2;
59 |
60 | switch (getMode()->getID())
61 | {
62 | case Mode::rms:
63 | {
64 | if (drag.ht == MainWindow::HitTest::VertScaleMin)
65 | theApp.setMinRMS(drag.origValue + offset);
66 | else
67 | theApp.setMaxRMS(drag.origValue + offset);
68 |
69 | break;
70 | }
71 | case Mode::center:
72 | {
73 | if (drag.ht == MainWindow::HitTest::VertScaleMin)
74 | theApp.setLimitVolume(drag.origValue - offset);
75 | else
76 | theApp.setLimitVolume(drag.origValue + offset);
77 |
78 | break;
79 | }
80 | case Mode::bottomUp:
81 | {
82 | theApp.setLimitVolume(drag.origValue + offset);
83 |
84 | break;
85 | }
86 | case Mode::topDown:
87 | {
88 | theApp.setLimitVolume(drag.origValue - offset);
89 |
90 | break;
91 | }
92 | }
93 |
94 | break;
95 | }
96 | }
97 | }
98 | else
99 | {
100 | // MY_TRACE(_T("ホットフレームを更新します\n"));
101 |
102 | int newHotFrame = client2frame(point.x);
103 |
104 | setHotFrame(newHotFrame);
105 | outputFrames();
106 | }
107 |
108 | return ::DefWindowProc(hwnd, message, wParam, lParam);
109 | }
110 |
111 | LRESULT MainWindow::onMouseWheel(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
112 | {
113 | int delta = (short)HIWORD(wParam);
114 | POINT point = LP2PT(lParam);
115 | ::MapWindowPoints(0, hwnd, &point, 1);
116 |
117 | MY_TRACE(_T("MainWindow::onMouseWheel(%d, %d, %d)\n"), delta, point.x, point.y);
118 |
119 | int newZoom = getZoom();
120 |
121 | if (delta > 0)
122 | {
123 | newZoom += 10;
124 | }
125 | else
126 | {
127 | newZoom -= 10;
128 | }
129 |
130 | theApp.setZoom(newZoom);
131 |
132 | return ::DefWindowProc(hwnd, message, wParam, lParam);
133 | }
134 |
135 | LRESULT MainWindow::onLButtonDown(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
136 | {
137 | MY_TRACE(_T("MainWindow::onLButtonDown(0x%08X, 0x%08X)\n"), wParam, lParam);
138 |
139 | POINT point = LP2PT(lParam);
140 |
141 | drag.ht = hitTest(point);
142 |
143 | switch (drag.ht)
144 | {
145 | case HitTest::HorzScale:
146 | {
147 | // zoom のドラッグを開始する。
148 |
149 | ::SetCapture(hwnd);
150 | drag.origPoint = point;
151 | drag.origValue = getZoom();
152 |
153 | break;
154 | }
155 | case HitTest::VertScaleMin:
156 | {
157 | // minRMS, limitVolume をドラッグを開始する。
158 |
159 | ::SetCapture(hwnd);
160 | drag.origPoint = point;
161 | drag.origValue = (getMode()->getID() == Mode::rms) ? getMinRMS() : getLimitVolume();
162 |
163 | break;
164 | }
165 | case HitTest::VertScaleMax:
166 | {
167 | // maxRMS, limitVolume をドラッグを開始する。
168 |
169 | ::SetCapture(hwnd);
170 | drag.origPoint = point;
171 | drag.origValue = (getMode()->getID() == Mode::rms) ? getMaxRMS() : getLimitVolume();
172 |
173 | break;
174 | }
175 | default:
176 | {
177 | // カレントフレームを変更する。
178 |
179 | int32_t frame = client2frame(point.x);
180 |
181 | ::PostMessage(theApp.windowContainer, WM_AVIUTL_FILTER_CHANGE_FRAME, (WPARAM)frame, 0);
182 |
183 | break;
184 | }
185 | }
186 |
187 | return ::DefWindowProc(hwnd, message, wParam, lParam);
188 | }
189 |
190 | LRESULT MainWindow::onLButtonUp(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
191 | {
192 | MY_TRACE(_T("MainWindow::onLButtonUp(0x%08X, 0x%08X)\n"), wParam, lParam);
193 |
194 | ::ReleaseCapture();
195 |
196 | return ::DefWindowProc(hwnd, message, wParam, lParam);
197 | }
198 |
199 | //--------------------------------------------------------------------
200 |
--------------------------------------------------------------------------------
/OutProcess/MainWindow_OpenGL.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 | #include "MainWindow.h"
3 |
4 | #define NANOVG_GL3_IMPLEMENTATION
5 | #include "NanoVG/nanovg_gl.h"
6 |
7 | //--------------------------------------------------------------------
8 |
9 | BOOL MainWindow::setupPixelFormat(HDC dc)
10 | {
11 | MY_TRACE(_T("MainWindow::setupPixelFormat(0x%08X)\n"), dc);
12 |
13 | PIXELFORMATDESCRIPTOR pfd =
14 | {
15 | sizeof(pfd),
16 | 1,
17 | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
18 | PFD_TYPE_RGBA,
19 | 24,
20 | 0, 0, 0, 0, 0, 0,
21 | 0,
22 | 0,
23 | 0,
24 | 0, 0, 0, 0,
25 | 32,
26 | 1,
27 | 0,
28 | PFD_MAIN_PLANE,
29 | 0,
30 | 0, 0, 0
31 | };
32 |
33 | int pixelFormat = ::ChoosePixelFormat(dc, &pfd);
34 | MY_TRACE_INT(pixelFormat);
35 |
36 | if (!pixelFormat)
37 | {
38 | MY_TRACE(_T("::ChoosePixelFormat() が失敗しました\n"));
39 |
40 | return FALSE;
41 | }
42 |
43 | if (!::SetPixelFormat(dc, pixelFormat, &pfd))
44 | {
45 | MY_TRACE(_T("::SetPixelFormat() が失敗しました\n"));
46 |
47 | return FALSE;
48 | }
49 |
50 | return TRUE;
51 | }
52 |
53 | BOOL MainWindow::initOpenGL()
54 | {
55 | MY_TRACE(_T("MainWindow::initOpenGL()\n"));
56 |
57 | // OpenGL を初期化する。
58 |
59 | ClientDC dc(m_hwnd);
60 |
61 | setupPixelFormat(dc);
62 |
63 | m_rc = wglCreateContext(dc);
64 | MY_TRACE_HEX(m_rc);
65 |
66 | if (!m_rc)
67 | {
68 | MY_TRACE(_T("wglCreateContext() が失敗しました\n"));
69 |
70 | return -1;
71 | }
72 |
73 | MakeCurrent makeCurrent(dc, m_rc);
74 |
75 | {
76 | // glad を初期化する。
77 |
78 | int result = gladLoaderLoadGL();
79 |
80 | MY_TRACE_INT(result);
81 | }
82 |
83 | // NanoVG を初期化する。
84 |
85 | m_vg = nvgCreateGL3(NVG_ANTIALIAS | NVG_STENCIL_STROKES);
86 | // m_vg = nvgCreateGL3(NVG_ANTIALIAS | NVG_STENCIL_STROKES | NVG_DEBUG);
87 | MY_TRACE_HEX(m_vg);
88 |
89 | return TRUE;
90 | }
91 |
92 | BOOL MainWindow::termOpenGL()
93 | {
94 | MY_TRACE(_T("MainWindow::termOpenGL()\n"));
95 |
96 | nvgDeleteGL3(m_vg), m_vg = 0;
97 |
98 | wglDeleteContext(m_rc), m_rc = 0;
99 |
100 | return TRUE;
101 | }
102 |
103 | //--------------------------------------------------------------------
104 |
--------------------------------------------------------------------------------
/OutProcess/MainWindow_Paint.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 | #include "MainWindow.h"
3 | #include "App.h"
4 |
5 | //--------------------------------------------------------------------
6 |
7 | void MainWindow::doPaint(HDC dc, const RECT& rc)
8 | {
9 | MY_TRACE(_T("MainWindow::doPaint(0x%08X)\n"), dc);
10 |
11 | MakeCurrent makeCurrent(dc, m_rc);
12 | int w = getWidth(rc);
13 | int h = getHeight(rc);
14 |
15 | glViewport(0, 0, w, h);
16 | glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
17 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
18 |
19 | nvgBeginFrame(m_vg, (float)w, (float)h, 1.0f);
20 | nvgSave(m_vg);
21 |
22 | nvgFontFaceId(m_vg, m_fontDefault);
23 |
24 | doPaint(rc);
25 |
26 | nvgRestore(m_vg);
27 | nvgEndFrame(m_vg);
28 |
29 | ::SwapBuffers(dc);
30 | }
31 |
32 | void MainWindow::doPaint(const RECT& rc)
33 | {
34 | if (!theApp.projectParams) return;
35 |
36 | LayoutContext context = {};
37 | if (!getLayoutContext(context, rc)) return;
38 |
39 | m_mode->drawBackground(*this, context);
40 | m_mode->drawScale(*this, context);
41 | m_mode->drawBody(*this, context);
42 | m_mode->drawGraph(*this, context);
43 | }
44 |
45 | //--------------------------------------------------------------------
46 |
47 | LRESULT MainWindow::onPaint(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
48 | {
49 | PaintDC dc(hwnd);
50 | RECT rc = dc.m_ps.rcPaint;
51 | doPaint(dc, rc);
52 |
53 | return 0;
54 | }
55 |
56 | //--------------------------------------------------------------------
57 |
--------------------------------------------------------------------------------
/OutProcess/Mode.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "OutProcess.h"
4 | #include "Design.h"
5 |
6 | //--------------------------------------------------------------------
7 |
8 | struct MainWindow;
9 | struct LayoutContext;
10 |
11 | //--------------------------------------------------------------------
12 |
13 | struct Mode
14 | {
15 | virtual int getID() const = 0;
16 |
17 | static NVGpaint nvgVertGradient(NVGcontext* vg, const XYWHRect& rc, const Design::GradientFill& design);
18 | static void nvgStrokeDesign(NVGcontext* vg, const Design::Stroke& stroke);
19 | static void nvgXYWHRect(NVGcontext* vg, const XYWHRect& rc);
20 | static void drawImage(NVGcontext* vg, int image, const XYWHRect& rc, const Design::Image& design);
21 | static void drawLine(NVGcontext* vg, float mx, float my, float lx, float ly, const Design::Stroke& stroke);
22 | static void drawText(NVGcontext* vg, LPCSTR text, float x, float y, const Design::Text& design);
23 | static void drawMarker(MainWindow& window, const LayoutContext& context, int frame, const Design::Marker& marker);
24 |
25 | virtual void drawBackground(MainWindow& window, const LayoutContext& context);
26 | virtual void drawBody(MainWindow& window, const LayoutContext& context);
27 | virtual void drawScale(MainWindow& window, const LayoutContext& context);
28 | virtual void drawHorzScale(MainWindow& window, const LayoutContext& context);
29 | virtual void drawVertScale(MainWindow& window, const LayoutContext& context);
30 | virtual void drawGraph(MainWindow& window, const LayoutContext& context);
31 |
32 | struct PointF { float x, y; };
33 |
34 | void drawBPM(MainWindow& window, const LayoutContext& context);
35 | void drawMarkers(MainWindow& window, const LayoutContext& context);
36 | void drawVertScaleLine(MainWindow& window, const LayoutContext& context, float y);
37 | void drawPoints(MainWindow& window, const LayoutContext& context, const std::vector& points);
38 | };
39 |
40 | struct RMSMode : public Mode
41 | {
42 | virtual int getID() const;
43 |
44 | virtual void drawVertScale(MainWindow& window, const LayoutContext& context);
45 | virtual void drawGraph(MainWindow& window, const LayoutContext& context);
46 | };
47 |
48 | struct CenterMode : public Mode
49 | {
50 | virtual int getID() const;
51 |
52 | virtual void drawVertScale(MainWindow& window, const LayoutContext& context);
53 | virtual void drawGraph(MainWindow& window, const LayoutContext& context);
54 | };
55 |
56 | struct BottomUpMode : public Mode
57 | {
58 | virtual int getID() const;
59 |
60 | virtual void drawVertScale(MainWindow& window, const LayoutContext& context);
61 | virtual void drawGraph(MainWindow& window, const LayoutContext& context);
62 | };
63 |
64 | struct TopDownMode : public Mode
65 | {
66 | virtual int getID() const;
67 |
68 | virtual void drawVertScale(MainWindow& window, const LayoutContext& context);
69 | virtual void drawGraph(MainWindow& window, const LayoutContext& context);
70 | };
71 |
72 | typedef std::shared_ptr ModePtr;
73 |
74 | //--------------------------------------------------------------------
75 |
--------------------------------------------------------------------------------
/OutProcess/Mode_BottomUp.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 | #include "Mode.h"
3 | #include "MainWindow.h"
4 | #include "App.h"
5 |
6 | //--------------------------------------------------------------------
7 |
8 | int BottomUpMode::getID() const
9 | {
10 | return MainWindow::Mode::bottomUp;
11 | }
12 |
13 | //--------------------------------------------------------------------
14 |
15 | void BottomUpMode::drawVertScale(MainWindow& window, const LayoutContext& context)
16 | {
17 | // 垂直目盛りを左右に描画する。
18 |
19 | if (window.m_limitVolume <= 0) return;
20 |
21 | NVGcontext* vg = window.m_vg;
22 | const LayoutContext::Graph& graph = context.graph;
23 |
24 | nvgScissor(vg, (float)context.x, (float)graph.y, (float)context.w, (float)graph.h);
25 |
26 | int textPadding = 4;
27 | int textHeight = g_design.scale.vert.text.height + textPadding * 2;
28 |
29 | int prev = -(textHeight + 1);
30 | for (int i = 0; i <= 10; i++)
31 | {
32 | int oy = graph.h * i / 10;
33 | if (oy - prev < textHeight) continue;
34 | prev = oy;
35 |
36 | float fy = (float)(graph.bottom - oy);
37 |
38 | drawVertScaleLine(window, context, fy);
39 |
40 | char text[MAX_PATH] = {};
41 | ::StringCbPrintfA(text, sizeof(text), "%d", window.m_limitVolume * i / 10);
42 |
43 | {
44 | nvgTextAlign(vg, NVG_ALIGN_RIGHT | NVG_ALIGN_BOTTOM);
45 |
46 | float tx = (float)(graph.left - textPadding);
47 | float ty = (float)(fy - textPadding);
48 |
49 | drawText(vg, text, tx, ty, g_design.scale.vert.text);
50 | }
51 |
52 | {
53 | nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_BOTTOM);
54 |
55 | float tx = (float)(graph.right + textPadding);
56 | float ty = (float)(fy - textPadding);
57 |
58 | drawText(vg, text, tx, ty, g_design.scale.vert.text);
59 | }
60 | }
61 |
62 | {
63 | // 基準音量を描画する。
64 |
65 | int y = graph.bottom - graph.h * window.m_baseVolume / window.m_limitVolume;
66 |
67 | if (y > graph.top && y < graph.bottom)
68 | {
69 | float fy = (float)y;
70 | float mx = (float)context.rc.left;
71 | float lx = (float)context.rc.right;
72 |
73 | drawLine(vg, mx, fy, lx, fy, g_design.scale.vert.base.stroke);
74 | }
75 | }
76 |
77 | nvgResetScissor(vg);
78 | }
79 |
80 | void BottomUpMode::drawGraph(MainWindow& window, const LayoutContext& context)
81 | {
82 | int c = (int)theApp.totals.size();
83 |
84 | if (c <= 0) return;
85 | if (window.m_limitVolume <= 0) return;
86 |
87 | NVGcontext* vg = window.m_vg;
88 | const LayoutContext::Graph& graph = context.graph;
89 |
90 | nvgScissor(vg, (float)graph.x, (float)graph.y, (float)graph.w, (float)graph.h);
91 |
92 | int ox = graph.x - context.hScroll; // 描画範囲の X 座標。
93 | int lh = graph.h * 100 / window.m_limitVolume;
94 |
95 | // グラフを描画する。
96 |
97 | std::vector points;
98 |
99 | {
100 | // まず、描画に必要な座標をすべて取得する。
101 |
102 | for (int i = 0; i < c; i++)
103 | {
104 | float level = theApp.totals[i].level;
105 | float x = (float)window.frame2client(i);
106 | float y = (float)graph.bottom - lh * level;
107 |
108 | points.emplace_back(x, y);
109 | }
110 | }
111 |
112 | {
113 | // グラフを塗りつぶす。
114 |
115 | nvgBeginPath(vg);
116 | nvgMoveTo(vg, (float)graph.left, (float)(graph.bottom + context.padding));
117 |
118 | for (const auto& point : points)
119 | nvgLineTo(vg, point.x, point.y);
120 |
121 | nvgLineTo(vg, (float)graph.right, (float)(graph.bottom + context.padding));
122 |
123 | NVGpaint paint = nvgLinearGradient(vg,
124 | (float)graph.left, (float)graph.top,
125 | (float)graph.left, (float)graph.bottom,
126 | g_design.graph.fill.color1, g_design.graph.fill.color2);
127 | nvgFillPaint(vg, paint);
128 | nvgFill(vg);
129 | }
130 |
131 | {
132 | // グラフのストロークを描画する。
133 |
134 | nvgBeginPath(vg);
135 | nvgMoveTo(vg, (float)graph.left, (float)graph.bottom);
136 |
137 | for (const auto& point : points)
138 | nvgLineTo(vg, point.x, point.y);
139 |
140 | nvgStrokeWidth(vg, (float)g_design.graph.stroke.width);
141 | nvgStrokeColor(vg, g_design.graph.stroke.color);
142 | nvgStroke(vg);
143 | }
144 |
145 | nvgResetScissor(vg);
146 |
147 | Mode::drawGraph(window, context);
148 | }
149 |
150 | //--------------------------------------------------------------------
151 |
--------------------------------------------------------------------------------
/OutProcess/Mode_Center.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 | #include "Mode.h"
3 | #include "MainWindow.h"
4 | #include "App.h"
5 |
6 | //--------------------------------------------------------------------
7 |
8 | int CenterMode::getID() const
9 | {
10 | return MainWindow::Mode::center;
11 | }
12 |
13 | //--------------------------------------------------------------------
14 |
15 | void CenterMode::drawVertScale(MainWindow& window, const LayoutContext& context)
16 | {
17 | // 垂直目盛りを左右に描画する。
18 |
19 | if (window.m_limitVolume <= 0) return;
20 |
21 | NVGcontext* vg = window.m_vg;
22 | const LayoutContext::Graph& graph = context.graph;
23 |
24 | nvgScissor(vg, (float)context.x, (float)graph.y, (float)context.w, (float)graph.h);
25 |
26 | int textPadding = 4;
27 | int textHeight = g_design.scale.vert.text.height + textPadding * 2;
28 | int cy = graph.y + graph.h / 2;
29 |
30 | int prev = -(textHeight + 1);
31 | for (int i = 0; i <= 10; i++)
32 | {
33 | int oy = graph.h * i / 10;
34 | if (oy - prev < textHeight) continue;
35 | prev = oy;
36 |
37 | int y[2] = { cy - oy, cy + oy };
38 | int c = (y[0] == y[1]) ? 1 : 2;
39 |
40 | for (int j = 0; j < c; j++)
41 | {
42 | drawVertScaleLine(window, context, (float)y[j]);
43 |
44 | char text[MAX_PATH] = {};
45 | ::StringCbPrintfA(text, sizeof(text), "%d", window.m_limitVolume * i / 10);
46 |
47 | {
48 | nvgTextAlign(vg, NVG_ALIGN_RIGHT | NVG_ALIGN_BOTTOM);
49 |
50 | float tx = (float)(graph.left - textPadding);
51 | float ty = (float)(y[j] - textPadding);
52 |
53 | drawText(vg, text, tx, ty, g_design.scale.vert.text);
54 | }
55 |
56 | {
57 | nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_BOTTOM);
58 |
59 | float tx = (float)(graph.right + textPadding);
60 | float ty = (float)(y[j] - textPadding);
61 |
62 | drawText(vg, text, tx, ty, g_design.scale.vert.text);
63 | }
64 | }
65 | }
66 |
67 | {
68 | // 基準音量を描画する。
69 |
70 | int oy = graph.h * window.m_baseVolume / window.m_limitVolume;
71 |
72 | for (int j = 0; j < 2; j++)
73 | {
74 | int y[2] = { cy - oy, cy + oy };
75 |
76 | if (y[j] > graph.top && y[j] < graph.bottom)
77 | {
78 | float fy = (float)y[j];
79 | float mx = (float)context.rc.left;
80 | float lx = (float)context.rc.right;
81 |
82 | drawLine(vg, mx, fy, lx, fy, g_design.scale.vert.base.stroke);
83 | }
84 | }
85 | }
86 |
87 | nvgResetScissor(vg);
88 | }
89 |
90 | void CenterMode::drawGraph(MainWindow& window, const LayoutContext& context)
91 | {
92 | int c = (int)theApp.totals.size();
93 |
94 | if (c <= 0) return;
95 | if (window.m_limitVolume <= 0) return;
96 |
97 | NVGcontext* vg = window.m_vg;
98 | const LayoutContext::Graph& graph = context.graph;
99 |
100 | nvgScissor(vg, (float)graph.x, (float)graph.y, (float)graph.w, (float)graph.h);
101 |
102 | int ox = graph.x - context.hScroll; // 描画範囲の X 座標。
103 | int lh = graph.h * 100 / window.m_limitVolume;
104 | int cy = graph.y + graph.h / 2;
105 |
106 | // グラフを描画する。
107 |
108 | std::vector points;
109 |
110 | {
111 | // まず、描画に必要な座標をすべて取得する。
112 |
113 | for (int i = 0; i < c; i++)
114 | {
115 | float level = theApp.totals[i].level;
116 | float x = (float)window.frame2client(i);
117 | float y = (float)lh * level;
118 |
119 | points.emplace_back(x, y);
120 | }
121 | }
122 |
123 | {
124 | // グラフを塗りつぶす。
125 |
126 | nvgBeginPath(vg);
127 | nvgMoveTo(vg, (float)graph.left, (float)cy);
128 |
129 | for (const auto& point : points)
130 | nvgLineTo(vg, point.x, cy - point.y);
131 |
132 | int c = (int)points.size();
133 | for (int i = c - 1; i >= 0; i--)
134 | nvgLineTo(vg, points[i].x, cy + points[i].y);
135 |
136 | NVGpaint paint = nvgLinearGradient(vg,
137 | (float)graph.left, (float)graph.top,
138 | (float)graph.left, (float)graph.bottom,
139 | g_design.graph.fill.color1, g_design.graph.fill.color2);
140 | nvgFillPaint(vg, paint);
141 | nvgFill(vg);
142 | }
143 |
144 | {
145 | // グラフのストロークを描画する。
146 |
147 | nvgBeginPath(vg);
148 | nvgMoveTo(vg, (float)graph.left, (float)cy);
149 |
150 | for (const auto& point : points)
151 | nvgLineTo(vg, point.x, cy - point.y);
152 |
153 | int c = (int)points.size();
154 | for (int i = c - 1; i >= 0; i--)
155 | nvgLineTo(vg, points[i].x, cy + points[i].y);
156 |
157 | nvgStrokeWidth(vg, (float)g_design.graph.stroke.width);
158 | nvgStrokeColor(vg, g_design.graph.stroke.color);
159 | nvgStroke(vg);
160 | }
161 |
162 | nvgResetScissor(vg);
163 |
164 | Mode::drawGraph(window, context);
165 | }
166 |
167 | //--------------------------------------------------------------------
168 |
--------------------------------------------------------------------------------
/OutProcess/Mode_RMS.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 | #include "Mode.h"
3 | #include "MainWindow.h"
4 | #include "App.h"
5 |
6 | //--------------------------------------------------------------------
7 |
8 | int RMSMode::getID() const
9 | {
10 | return MainWindow::Mode::rms;
11 | }
12 |
13 | //--------------------------------------------------------------------
14 |
15 | void RMSMode::drawVertScale(MainWindow& window, const LayoutContext& context)
16 | {
17 | // 垂直目盛りを左右に描画する。
18 |
19 | NVGcontext* vg = window.m_vg;
20 | const LayoutContext::Graph& graph = context.graph;
21 |
22 | nvgScissor(vg, (float)context.x, (float)graph.y, (float)context.w, (float)graph.h);
23 |
24 | int textPadding = 4;
25 | int textHeight = g_design.scale.vert.text.height + textPadding * 2;
26 |
27 | int minRMS = window.getMinRMS();
28 | int maxRMS = window.getMaxRMS();
29 | int baseRMS = window.getBaseRMS();
30 |
31 | float range = (float)(maxRMS - minRMS);
32 | MY_TRACE_REAL(range);
33 | int freq = (int)(range * textHeight / graph.h) + 1;
34 | MY_TRACE_INT(freq);
35 |
36 | for (int i = maxRMS; i > minRMS - freq; i--)
37 | {
38 | if (i % freq) continue;
39 |
40 | float relativeLevel = (float)(i - minRMS);
41 | int y = (int)(graph.y + graph.h * (1.0f - relativeLevel / range));
42 | float fy = (float)y;
43 |
44 | drawVertScaleLine(window, context, fy);
45 |
46 | char text[MAX_PATH] = {};
47 | ::StringCbPrintfA(text, sizeof(text), "%+d", i);
48 |
49 | {
50 | nvgTextAlign(vg, NVG_ALIGN_RIGHT | NVG_ALIGN_BOTTOM);
51 |
52 | float tx = (float)(graph.left - textPadding);
53 | float ty = (float)(y - textPadding);
54 |
55 | drawText(vg, text, tx, ty, g_design.scale.vert.text);
56 | }
57 |
58 | {
59 | nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_BOTTOM);
60 |
61 | float tx = (float)(graph.right + textPadding);
62 | float ty = (float)(y - textPadding);
63 |
64 | drawText(vg, text, tx, ty, g_design.scale.vert.text);
65 | }
66 | }
67 |
68 | {
69 | // 基準 RMS を描画する。
70 |
71 | float relativeLevel = (float)(baseRMS - minRMS);
72 | int y = (int)(graph.top + graph.h * (1.0f - relativeLevel / range));
73 |
74 | if (y > graph.top && y < graph.bottom)
75 | {
76 | float fy = (float)y;
77 | float mx = (float)context.rc.left;
78 | float lx = (float)context.rc.right;
79 |
80 | drawLine(vg, mx, fy, lx, fy, g_design.scale.vert.base.stroke);
81 | }
82 | }
83 |
84 | nvgResetScissor(vg);
85 | }
86 |
87 | void RMSMode::drawGraph(MainWindow& window, const LayoutContext& context)
88 | {
89 | int c = (int)theApp.totals.size();
90 |
91 | if (c <= 0) return;
92 |
93 | NVGcontext* vg = window.m_vg;
94 | const LayoutContext::Graph& graph = context.graph;
95 |
96 | nvgScissor(vg, (float)graph.x, (float)graph.y, (float)graph.w, (float)graph.h);
97 |
98 | int ox = graph.x - context.hScroll; // 描画範囲の X 座標。
99 | int minRMS = window.getMinRMS();
100 | int maxRMS = window.getMaxRMS();
101 |
102 | // グラフを描画する。
103 |
104 | std::vector points;
105 |
106 | {
107 | // まず、描画に必要な座標をすべて取得する。
108 |
109 | for (int i = 0; i < c; i++)
110 | {
111 | float level = (theApp.totals[i].rms - minRMS) / (maxRMS - minRMS);
112 | float x = (float)window.frame2client(i);
113 | float y = std::min((float)graph.bottom, (float)graph.bottom - graph.h * level);
114 |
115 | points.emplace_back(x, y);
116 | }
117 | }
118 |
119 | {
120 | // グラフを塗りつぶす。
121 |
122 | nvgBeginPath(vg);
123 | nvgMoveTo(vg, (float)graph.left, (float)(graph.bottom + context.padding));
124 |
125 | for (const auto& point : points)
126 | nvgLineTo(vg, point.x, point.y);
127 |
128 | nvgLineTo(vg, (float)graph.right, (float)(graph.bottom + context.padding));
129 | // nvgClosePath(vg);
130 | // nvgPathWinding(vg, NVG_SOLID);
131 |
132 | NVGpaint paint = nvgLinearGradient(vg,
133 | (float)graph.left, (float)graph.top,
134 | (float)graph.left, (float)graph.bottom,
135 | g_design.graph.fill.color1, g_design.graph.fill.color2);
136 | nvgFillPaint(vg, paint);
137 | nvgFill(vg);
138 | }
139 |
140 | {
141 | // グラフのストロークを描画する。
142 |
143 | nvgBeginPath(vg);
144 | nvgMoveTo(vg, (float)graph.left, (float)graph.bottom);
145 |
146 | for (const auto& point : points)
147 | nvgLineTo(vg, point.x, point.y);
148 |
149 | nvgStrokeWidth(vg, (float)g_design.graph.stroke.width);
150 | nvgStrokeColor(vg, g_design.graph.stroke.color);
151 | nvgStroke(vg);
152 | }
153 |
154 | nvgResetScissor(vg);
155 |
156 | Mode::drawGraph(window, context);
157 | }
158 |
159 | //--------------------------------------------------------------------
160 |
--------------------------------------------------------------------------------
/OutProcess/Mode_TopDown.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 | #include "Mode.h"
3 | #include "MainWindow.h"
4 | #include "App.h"
5 |
6 | //--------------------------------------------------------------------
7 |
8 | int TopDownMode::getID() const
9 | {
10 | return MainWindow::Mode::topDown;
11 | }
12 |
13 | //--------------------------------------------------------------------
14 |
15 | void TopDownMode::drawVertScale(MainWindow& window, const LayoutContext& context)
16 | {
17 | // 垂直目盛りを左右に描画する。
18 |
19 | if (window.m_limitVolume <= 0) return;
20 |
21 | NVGcontext* vg = window.m_vg;
22 | const LayoutContext::Graph& graph = context.graph;
23 |
24 | nvgScissor(vg, (float)context.x, (float)graph.y, (float)context.w, (float)graph.h);
25 |
26 | int textPadding = 4;
27 | int textHeight = g_design.scale.vert.text.height + textPadding * 2;
28 |
29 | int prev = -(textHeight + 1);
30 | for (int i = 0; i <= 10; i++)
31 | {
32 | int oy = graph.h * i / 10;
33 | if (oy - prev < textHeight) continue;
34 | prev = oy;
35 |
36 | float fy = (float)(graph.top + oy);
37 |
38 | drawVertScaleLine(window, context, fy);
39 |
40 | char text[MAX_PATH] = {};
41 | ::StringCbPrintfA(text, sizeof(text), "%d", window.m_limitVolume * i / 10);
42 |
43 | {
44 | nvgTextAlign(vg, NVG_ALIGN_RIGHT | NVG_ALIGN_BOTTOM);
45 |
46 | float tx = (float)(graph.left - textPadding);
47 | float ty = (float)(fy - textPadding);
48 |
49 | drawText(vg, text, tx, ty, g_design.scale.vert.text);
50 | }
51 |
52 | {
53 | nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_BOTTOM);
54 |
55 | float tx = (float)(graph.right + textPadding);
56 | float ty = (float)(fy - textPadding);
57 |
58 | drawText(vg, text, tx, ty, g_design.scale.vert.text);
59 | }
60 | }
61 |
62 | {
63 | // 基準音量を描画する。
64 |
65 | int y = graph.top + graph.h * window.m_baseVolume / window.m_limitVolume;
66 |
67 | if (y > graph.top && y < graph.bottom)
68 | {
69 | float fy = (float)y;
70 | float mx = (float)context.rc.left;
71 | float lx = (float)context.rc.right;
72 |
73 | drawLine(vg, mx, fy, lx, fy, g_design.scale.vert.base.stroke);
74 | }
75 | }
76 |
77 | nvgResetScissor(vg);
78 | }
79 |
80 | void TopDownMode::drawGraph(MainWindow& window, const LayoutContext& context)
81 | {
82 | int c = (int)theApp.totals.size();
83 |
84 | if (c <= 0) return;
85 | if (window.m_limitVolume <= 0) return;
86 |
87 | NVGcontext* vg = window.m_vg;
88 | const LayoutContext::Graph& graph = context.graph;
89 |
90 | nvgScissor(vg, (float)graph.x, (float)graph.y, (float)graph.w, (float)graph.h);
91 |
92 | int ox = graph.x - context.hScroll; // 描画範囲の X 座標。
93 | int lh = graph.h * 100 / window.m_limitVolume;
94 |
95 | // グラフを描画する。
96 |
97 | std::vector points;
98 |
99 | {
100 | // まず、描画に必要な座標をすべて取得する。
101 |
102 | for (int i = 0; i < c; i++)
103 | {
104 | float level = theApp.totals[i].level;
105 | float x = (float)window.frame2client(i);
106 | float y = (float)graph.top + lh * level;
107 |
108 | points.emplace_back(x, y);
109 | }
110 | }
111 |
112 | {
113 | // グラフを塗りつぶす。
114 |
115 | nvgBeginPath(vg);
116 | nvgMoveTo(vg, (float)graph.left, (float)(graph.top - context.padding));
117 |
118 | for (const auto& point : points)
119 | nvgLineTo(vg, point.x, point.y);
120 |
121 | nvgLineTo(vg, (float)graph.right, (float)(graph.top - context.padding));
122 |
123 | NVGpaint paint = nvgLinearGradient(vg,
124 | (float)graph.left, (float)graph.top,
125 | (float)graph.left, (float)graph.bottom,
126 | g_design.graph.fill.color1, g_design.graph.fill.color2);
127 | nvgFillPaint(vg, paint);
128 | nvgFill(vg);
129 | }
130 |
131 | {
132 | // グラフのストロークを描画する。
133 |
134 | nvgBeginPath(vg);
135 | nvgMoveTo(vg, (float)graph.left, (float)graph.top);
136 |
137 | for (const auto& point : points)
138 | nvgLineTo(vg, point.x, point.y);
139 |
140 | nvgStrokeWidth(vg, (float)g_design.graph.stroke.width);
141 | nvgStrokeColor(vg, g_design.graph.stroke.color);
142 | nvgStroke(vg);
143 | }
144 |
145 | nvgResetScissor(vg);
146 |
147 | Mode::drawGraph(window, context);
148 | }
149 |
150 | //--------------------------------------------------------------------
151 |
--------------------------------------------------------------------------------
/OutProcess/OutProcess.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 |
3 | //--------------------------------------------------------------------
4 |
--------------------------------------------------------------------------------
/OutProcess/OutProcess.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | //--------------------------------------------------------------------
4 |
5 | struct Label {
6 | int value;
7 | LPCWSTR label;
8 | };
9 |
10 | //--------------------------------------------------------------------
11 |
--------------------------------------------------------------------------------
/OutProcess/OutProcess.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hebiiro/AviUtl-Plugin-ShowWaveform/ada292c648f8d941588c9261710214e157c187ef/OutProcess/OutProcess.rc
--------------------------------------------------------------------------------
/OutProcess/OutProcess.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 16.0
23 | Win32Proj
24 | {3e78d513-8512-4a92-8896-6c1e074647ea}
25 | OutProcess
26 | 10.0
27 |
28 |
29 |
30 | Application
31 | true
32 | v143
33 | Unicode
34 |
35 |
36 | Application
37 | false
38 | v143
39 | true
40 | Unicode
41 |
42 |
43 | Application
44 | true
45 | v143
46 | Unicode
47 |
48 |
49 | Application
50 | false
51 | v143
52 | true
53 | Unicode
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 | true
79 |
80 |
81 | false
82 |
83 |
84 | true
85 |
86 |
87 | false
88 |
89 |
90 |
91 | Level3
92 | true
93 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
94 | true
95 | Use
96 | pch.h
97 | stdcpplatest
98 |
99 |
100 | Windows
101 | true
102 |
103 |
104 | copy /B /Y "$(TargetDir)$(TargetFileName)" "C:\MySpace\AviUtl\AviUtl110_test\Plugins\$(SolutionName)\$(SolutionName).exe"
105 |
106 |
107 |
108 |
109 |
110 | Level3
111 | true
112 | true
113 | true
114 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
115 | true
116 | Use
117 | pch.h
118 | stdcpplatest
119 |
120 |
121 | Windows
122 | true
123 | true
124 | true
125 |
126 |
127 | copy /B /Y "$(TargetDir)$(TargetFileName)" "C:\MySpace\AviUtl\AviUtl110_test\Plugins\$(SolutionName)\$(SolutionName).exe"
128 |
129 |
130 |
131 |
132 |
133 | Level3
134 | true
135 | _DEBUG;_WINDOWS;%(PreprocessorDefinitions)
136 | true
137 | Use
138 | pch.h
139 | stdcpplatest
140 |
141 |
142 | Windows
143 | true
144 |
145 |
146 | copy /B /Y "$(TargetDir)$(TargetFileName)" "C:\AviUtl110_test\Plugins\$(SolutionName)\$(SolutionName).exe"
147 |
148 |
149 |
150 |
151 |
152 | Level3
153 | true
154 | true
155 | true
156 | NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
157 | true
158 | Use
159 | pch.h
160 | stdcpplatest
161 |
162 |
163 | Windows
164 | true
165 | true
166 | true
167 |
168 |
169 | copy /B /Y "$(TargetDir)$(TargetFileName)" "C:\AviUtl110_test\Plugins\$(SolutionName)\$(SolutionName).exe"
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 | Create
208 | Create
209 | Create
210 | Create
211 |
212 |
213 |
214 |
215 |
216 |
217 | {db2053e8-60d4-4bd5-845a-11ca24e2c599}
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
--------------------------------------------------------------------------------
/OutProcess/OutProcess.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {b2b8b579-a036-4aeb-aa10-399e689a71f3}
6 |
7 |
8 | {639143d2-2767-4514-ba40-4e8535d9fa7e}
9 |
10 |
11 |
12 |
13 | Framework
14 |
15 |
16 | Framework
17 |
18 |
19 | Framework
20 |
21 |
22 |
23 |
24 |
25 |
26 | Resource
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | Framework
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | Resource
61 |
62 |
63 |
--------------------------------------------------------------------------------
/OutProcess/ReaderManager.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 | #include "ReaderManager.h"
3 | #include "App.h"
4 |
5 | //--------------------------------------------------------------------
6 |
7 | Reader::Reader(HWND hwnd)
8 | {
9 | MY_TRACE(_T("Reader::Reader(0x%08p)\n"), hwnd);
10 |
11 | TCHAR path[MAX_PATH] = {};
12 | ::GetModuleFileName(theApp.instance, path, MAX_PATH);
13 | ::PathRemoveFileSpec(path);
14 | ::PathAppend(path, _T("ReaderProcess.exe"));
15 | MY_TRACE_TSTR(path);
16 |
17 | TCHAR args[MAX_PATH] = {};
18 | ::StringCbPrintf(args, sizeof(args), _T("0x%08p"), hwnd);
19 | MY_TRACE_TSTR(args);
20 |
21 | STARTUPINFO si = { sizeof(si) };
22 | if (!::CreateProcess(
23 | path, // No module name (use command line)
24 | args, // Command line
25 | NULL, // Process handle not inheritable
26 | NULL, // Thread handle not inheritable
27 | FALSE, // Set handle inheritance to FALSE
28 | 0, // No creation flags
29 | NULL, // Use parent's environment block
30 | NULL, // Use parent's starting directory
31 | &si, // Pointer to STARTUPINFO structure
32 | &pi)) // Pointer to PROCESS_INFORMATION structure
33 | {
34 | MY_TRACE(_T("::CreateProcess() failed.\n"));
35 |
36 | return;
37 | }
38 |
39 | shared.init(getSharedReaderBottleName(getId()));
40 | }
41 |
42 | Reader::~Reader()
43 | {
44 | MY_TRACE(_T("Reader::~Reader() : %d, %d\n"), pi.dwProcessId, pi.dwThreadId);
45 |
46 | ::CloseHandle(pi.hThread);
47 | ::CloseHandle(pi.hProcess);
48 | }
49 |
50 | DWORD Reader::getId()
51 | {
52 | return pi.dwThreadId;
53 | }
54 |
55 | ReaderBottle* Reader::getBottle()
56 | {
57 | return shared.getBuffer();
58 | }
59 |
60 | //--------------------------------------------------------------------
61 |
62 | // リーダーを取得する。
63 | ReaderPtr ReaderManager::getReader(DWORD id)
64 | {
65 | auto it = readerMap.find(id);
66 | if (it == readerMap.end()) return 0;
67 | return it->second;
68 | }
69 |
70 | // リーダーを作成する。
71 | ReaderPtr ReaderManager::createReader(LPCSTR fileName)
72 | {
73 | MY_TRACE(_T("ReaderManager::createReader(%hs)\n"), fileName);
74 |
75 | ReaderPtr reader = std::make_shared(theApp.mainWindow);
76 | ReaderBottle* shared = reader->getBottle();
77 | if (!shared) return 0;
78 | ::StringCbCopyA(shared->fileName, sizeof(shared->fileName), fileName);
79 | readerMap[reader->getId()] = reader;
80 | return reader;
81 | }
82 |
83 | // リーダーを削除する。
84 | void ReaderManager::eraseReader(DWORD id)
85 | {
86 | MY_TRACE(_T("ReaderManager::eraseReader(%d)\n"), id);
87 |
88 | readerMap.erase(id);
89 | }
90 |
91 | BOOL ReaderManager::hasEmpty()
92 | {
93 | return (int)readerMap.size() < maxReaderCount;
94 | }
95 |
96 | //--------------------------------------------------------------------
97 |
--------------------------------------------------------------------------------
/OutProcess/ReaderManager.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | //--------------------------------------------------------------------
4 |
5 | struct Reader {
6 | PROCESS_INFORMATION pi = {};
7 | SimpleFileMappingT shared;
8 | Reader(HWND hwnd);
9 | ~Reader();
10 | DWORD getId();
11 | ReaderBottle* getBottle();
12 | };
13 |
14 | typedef std::shared_ptr ReaderPtr;
15 | typedef std::map ReaderMap;
16 |
17 | //--------------------------------------------------------------------
18 |
19 | struct ReaderManager {
20 | ReaderMap readerMap;
21 | int maxReaderCount = 1;
22 |
23 | ReaderPtr getReader(DWORD id);
24 | ReaderPtr createReader(LPCSTR fileName);
25 | void eraseReader(DWORD id);
26 | BOOL hasEmpty();
27 | };
28 |
29 | //--------------------------------------------------------------------
30 |
--------------------------------------------------------------------------------
/OutProcess/WaiterManager.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 | #include "WaiterManager.h"
3 |
4 | //--------------------------------------------------------------------
5 |
6 | Waiter::Waiter(LPCSTR fileName)
7 | : fileName(fileName)
8 | {
9 | }
10 |
11 | //--------------------------------------------------------------------
12 |
13 | WaiterPtr WaiterManager::createWaiter(LPCSTR fileName)
14 | {
15 | MY_TRACE(_T("WaiterManager::createWaiter(%hs)\n"), fileName);
16 |
17 | auto it = std::find_if(waiterQueue.begin(), waiterQueue.end(),
18 | [fileName](const WaiterPtr& waiter){ return waiter->fileName == fileName; });
19 | if (it != waiterQueue.end())
20 | return FALSE; // 既にキューに存在するので何もしない。
21 |
22 | WaiterPtr waiter = std::make_shared(fileName);
23 | waiterQueue.emplace_back(waiter);
24 | return waiter;
25 | }
26 |
27 | // ウェイターを消化する。
28 | void WaiterManager::digestWaiterQueue(ReaderManager& readerManager)
29 | {
30 | MY_TRACE(_T("WaiterManager::digestWaiterQueue()\n"));
31 |
32 | // ウェイターが存在し、なおかつリーダーの数に空きがあるなら
33 | while (!waiterQueue.empty() && readerManager.hasEmpty())
34 | {
35 | // ウェイターを取得する。
36 | const WaiterPtr& waiter = waiterQueue.front();
37 |
38 | // リーダーを作成する。
39 | ReaderPtr reader = readerManager.createReader(waiter->fileName.c_str());
40 |
41 | // ウェイターを削除する。
42 | waiterQueue.pop_front();
43 | }
44 |
45 | MY_TRACE_INT(waiterQueue.size());
46 | MY_TRACE_INT(readerManager.readerMap.size());
47 | }
48 |
49 | //--------------------------------------------------------------------
50 |
--------------------------------------------------------------------------------
/OutProcess/WaiterManager.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "OutProcess.h"
4 | #include "ReaderManager.h"
5 |
6 | //--------------------------------------------------------------------
7 |
8 | struct Waiter {
9 | std::string fileName;
10 | Waiter(LPCSTR fileName);
11 | };
12 |
13 | typedef std::shared_ptr WaiterPtr;
14 | typedef std::deque WaiterQueue;
15 |
16 | //--------------------------------------------------------------------
17 |
18 | struct WaiterManager {
19 | WaiterQueue waiterQueue;
20 | WaiterPtr createWaiter(LPCSTR fileName);
21 | void digestWaiterQueue(ReaderManager& readerManager);
22 | };
23 |
24 | //--------------------------------------------------------------------
25 |
--------------------------------------------------------------------------------
/OutProcess/framework.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "targetver.h"
4 | #define WIN32_LEAN_AND_MEAN
5 | #define NOMINMAX
6 | #include
7 | #include
8 | #include
9 | #pragma comment(lib, "shlwapi.lib")
10 | #include
11 | #pragma comment(lib, "comctl32.lib")
12 | #include
13 | #pragma comment(lib, "comdlg32.lib")
14 | #include
15 | #include
16 | #include
17 | #pragma comment(lib, "winmm.lib")
18 | #include
19 | #pragma comment(lib, "opengl32.lib")
20 | #pragma comment(lib, "glu32.lib")
21 | #include
22 | #include
23 |
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include