├── .gitattributes
├── .gitignore
├── Audio Visualizer.sln
├── Audio Visualizer
├── AudioVisualizer.csproj
├── FreqVisualizerAccord.cs
├── FreqVisualizerMathNet.cs
├── FreqVisualizerNAudio.cs
├── Oscilloscope.cs
├── OscilloscopeBWP.cs
├── OscilloscopeImproved.cs
├── OscilloscopeMusicVisualizer.cs
├── OscilloscopeMusicVisualizerImproved.cs
├── Program.cs
└── VisualizerWindow.cs
├── LICENSE.txt
└── README.md
/.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 | # Build results
17 | [Dd]ebug/
18 | [Dd]ebugPublic/
19 | [Rr]elease/
20 | [Rr]eleases/
21 | x64/
22 | x86/
23 | [Aa][Rr][Mm]/
24 | [Aa][Rr][Mm]64/
25 | bld/
26 | [Bb]in/
27 | [Oo]bj/
28 | [Ll]og/
29 |
30 | # Visual Studio 2015/2017 cache/options directory
31 | .vs/
32 | # Uncomment if you have tasks that create the project's static files in wwwroot
33 | #wwwroot/
34 |
35 | # Visual Studio 2017 auto generated files
36 | Generated\ Files/
37 |
38 | # MSTest test Results
39 | [Tt]est[Rr]esult*/
40 | [Bb]uild[Ll]og.*
41 |
42 | # NUNIT
43 | *.VisualState.xml
44 | TestResult.xml
45 |
46 | # Build Results of an ATL Project
47 | [Dd]ebugPS/
48 | [Rr]eleasePS/
49 | dlldata.c
50 |
51 | # Benchmark Results
52 | BenchmarkDotNet.Artifacts/
53 |
54 | # .NET Core
55 | project.lock.json
56 | project.fragment.lock.json
57 | artifacts/
58 |
59 | # StyleCop
60 | StyleCopReport.xml
61 |
62 | # Files built by Visual Studio
63 | *_i.c
64 | *_p.c
65 | *_h.h
66 | *.ilk
67 | *.meta
68 | *.obj
69 | *.iobj
70 | *.pch
71 | *.pdb
72 | *.ipdb
73 | *.pgc
74 | *.pgd
75 | *.rsp
76 | *.sbr
77 | *.tlb
78 | *.tli
79 | *.tlh
80 | *.tmp
81 | *.tmp_proj
82 | *_wpftmp.csproj
83 | *.log
84 | *.vspscc
85 | *.vssscc
86 | .builds
87 | *.pidb
88 | *.svclog
89 | *.scc
90 |
91 | # Chutzpah Test files
92 | _Chutzpah*
93 |
94 | # Visual C++ cache files
95 | ipch/
96 | *.aps
97 | *.ncb
98 | *.opendb
99 | *.opensdf
100 | *.sdf
101 | *.cachefile
102 | *.VC.db
103 | *.VC.VC.opendb
104 |
105 | # Visual Studio profiler
106 | *.psess
107 | *.vsp
108 | *.vspx
109 | *.sap
110 |
111 | # Visual Studio Trace Files
112 | *.e2e
113 |
114 | # TFS 2012 Local Workspace
115 | $tf/
116 |
117 | # Guidance Automation Toolkit
118 | *.gpState
119 |
120 | # ReSharper is a .NET coding add-in
121 | _ReSharper*/
122 | *.[Rr]e[Ss]harper
123 | *.DotSettings.user
124 |
125 | # JustCode is a .NET coding add-in
126 | .JustCode
127 |
128 | # TeamCity is a build add-in
129 | _TeamCity*
130 |
131 | # DotCover is a Code Coverage Tool
132 | *.dotCover
133 |
134 | # AxoCover is a Code Coverage Tool
135 | .axoCover/*
136 | !.axoCover/settings.json
137 |
138 | # Visual Studio code coverage results
139 | *.coverage
140 | *.coveragexml
141 |
142 | # NCrunch
143 | _NCrunch_*
144 | .*crunch*.local.xml
145 | nCrunchTemp_*
146 |
147 | # MightyMoose
148 | *.mm.*
149 | AutoTest.Net/
150 |
151 | # Web workbench (sass)
152 | .sass-cache/
153 |
154 | # Installshield output folder
155 | [Ee]xpress/
156 |
157 | # DocProject is a documentation generator add-in
158 | DocProject/buildhelp/
159 | DocProject/Help/*.HxT
160 | DocProject/Help/*.HxC
161 | DocProject/Help/*.hhc
162 | DocProject/Help/*.hhk
163 | DocProject/Help/*.hhp
164 | DocProject/Help/Html2
165 | DocProject/Help/html
166 |
167 | # Click-Once directory
168 | publish/
169 |
170 | # Publish Web Output
171 | *.[Pp]ublish.xml
172 | *.azurePubxml
173 | # Note: Comment the next line if you want to checkin your web deploy settings,
174 | # but database connection strings (with potential passwords) will be unencrypted
175 | *.pubxml
176 | *.publishproj
177 |
178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
179 | # checkin your Azure Web App publish settings, but sensitive information contained
180 | # in these scripts will be unencrypted
181 | PublishScripts/
182 |
183 | # NuGet Packages
184 | *.nupkg
185 | # The packages folder can be ignored because of Package Restore
186 | **/[Pp]ackages/*
187 | # except build/, which is used as an MSBuild target.
188 | !**/[Pp]ackages/build/
189 | # Uncomment if necessary however generally it will be regenerated when needed
190 | #!**/[Pp]ackages/repositories.config
191 | # NuGet v3's project.json files produces more ignorable files
192 | *.nuget.props
193 | *.nuget.targets
194 |
195 | # Microsoft Azure Build Output
196 | csx/
197 | *.build.csdef
198 |
199 | # Microsoft Azure Emulator
200 | ecf/
201 | rcf/
202 |
203 | # Windows Store app package directories and files
204 | AppPackages/
205 | BundleArtifacts/
206 | Package.StoreAssociation.xml
207 | _pkginfo.txt
208 | *.appx
209 |
210 | # Visual Studio cache files
211 | # files ending in .cache can be ignored
212 | *.[Cc]ache
213 | # but keep track of directories ending in .cache
214 | !?*.[Cc]ache/
215 |
216 | # Others
217 | ClientBin/
218 | ~$*
219 | *~
220 | *.dbmdl
221 | *.dbproj.schemaview
222 | *.jfm
223 | *.pfx
224 | *.publishsettings
225 | orleans.codegen.cs
226 |
227 | # Including strong name files can present a security risk
228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
229 | #*.snk
230 |
231 | # Since there are multiple workflows, uncomment next line to ignore bower_components
232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
233 | #bower_components/
234 |
235 | # RIA/Silverlight projects
236 | Generated_Code/
237 |
238 | # Backup & report files from converting an old project file
239 | # to a newer Visual Studio version. Backup files are not needed,
240 | # because we have git ;-)
241 | _UpgradeReport_Files/
242 | Backup*/
243 | UpgradeLog*.XML
244 | UpgradeLog*.htm
245 | ServiceFabricBackup/
246 | *.rptproj.bak
247 |
248 | # SQL Server files
249 | *.mdf
250 | *.ldf
251 | *.ndf
252 |
253 | # Business Intelligence projects
254 | *.rdl.data
255 | *.bim.layout
256 | *.bim_*.settings
257 | *.rptproj.rsuser
258 | *- Backup*.rdl
259 |
260 | # Microsoft Fakes
261 | FakesAssemblies/
262 |
263 | # GhostDoc plugin setting file
264 | *.GhostDoc.xml
265 |
266 | # Node.js Tools for Visual Studio
267 | .ntvs_analysis.dat
268 | node_modules/
269 |
270 | # Visual Studio 6 build log
271 | *.plg
272 |
273 | # Visual Studio 6 workspace options file
274 | *.opt
275 |
276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
277 | *.vbw
278 |
279 | # Visual Studio LightSwitch build output
280 | **/*.HTMLClient/GeneratedArtifacts
281 | **/*.DesktopClient/GeneratedArtifacts
282 | **/*.DesktopClient/ModelManifest.xml
283 | **/*.Server/GeneratedArtifacts
284 | **/*.Server/ModelManifest.xml
285 | _Pvt_Extensions
286 |
287 | # Paket dependency manager
288 | .paket/paket.exe
289 | paket-files/
290 |
291 | # FAKE - F# Make
292 | .fake/
293 |
294 | # JetBrains Rider
295 | .idea/
296 | *.sln.iml
297 |
298 | # CodeRush personal settings
299 | .cr/personal
300 |
301 | # Python Tools for Visual Studio (PTVS)
302 | __pycache__/
303 | *.pyc
304 |
305 | # Cake - Uncomment if you are using it
306 | # tools/**
307 | # !tools/packages.config
308 |
309 | # Tabs Studio
310 | *.tss
311 |
312 | # Telerik's JustMock configuration file
313 | *.jmconfig
314 |
315 | # BizTalk build output
316 | *.btp.cs
317 | *.btm.cs
318 | *.odx.cs
319 | *.xsd.cs
320 |
321 | # OpenCover UI analysis results
322 | OpenCover/
323 |
324 | # Azure Stream Analytics local run output
325 | ASALocalRun/
326 |
327 | # MSBuild Binary and Structured Log
328 | *.binlog
329 |
330 | # NVidia Nsight GPU debugger configuration file
331 | *.nvuser
332 |
333 | # MFractors (Xamarin productivity tool) working folder
334 | .mfractor/
335 |
336 | # Local History for Visual Studio
337 | .localhistory/
338 |
339 | # BeatPulse healthcheck temp database
340 | healthchecksdb
--------------------------------------------------------------------------------
/Audio Visualizer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29324.140
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AudioVisualizer", "Audio Visualizer\AudioVisualizer.csproj", "{7B0ADF17-CB4E-4021-8718-7D40BED04383}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{35B767B1-7E77-4813-9617-C5B8BBD710E4}"
9 | ProjectSection(SolutionItems) = preProject
10 | LICENSE.txt = LICENSE.txt
11 | README.md = README.md
12 | EndProjectSection
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|Any CPU = Debug|Any CPU
17 | Release|Any CPU = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {7B0ADF17-CB4E-4021-8718-7D40BED04383}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {7B0ADF17-CB4E-4021-8718-7D40BED04383}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {7B0ADF17-CB4E-4021-8718-7D40BED04383}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {7B0ADF17-CB4E-4021-8718-7D40BED04383}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {5B9F9466-19F5-45A2-8E00-C16E8DF00E95}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/Audio Visualizer/AudioVisualizer.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.1
6 | Audio_Visualizer
7 | Debug;Release;Mac
8 |
9 |
10 |
11 | 3
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Audio Visualizer/FreqVisualizerAccord.cs:
--------------------------------------------------------------------------------
1 | using Love;
2 | using NAudio.Wave;
3 | using System;
4 | using System.Numerics;
5 | using Accord.Math;
6 |
7 | namespace AudioVisualizer
8 | {
9 | /*
10 | * Visualizer using frequencies
11 | */
12 | class FreqVisualizerAccord : VisualizerWindow
13 | {
14 | private WaveBuffer buffer;
15 |
16 | private int Size = 2048;
17 |
18 | private int Intensity = 2;
19 |
20 | public override void Load()
21 | {
22 | WindowTitle = "Frequency Visualizer";
23 | base.Load();
24 |
25 | // start audio capture
26 | var capture = new WasapiLoopbackCapture();
27 |
28 | capture.DataAvailable += DataAvailable;
29 |
30 | capture.RecordingStopped += (s, a) =>
31 | {
32 | capture.Dispose();
33 | };
34 |
35 | capture.StartRecording();
36 | }
37 |
38 | public void DataAvailable(object sender, WaveInEventArgs e)
39 | {
40 | buffer = new WaveBuffer(e.Buffer); // save the buffer in the class variable
41 | }
42 |
43 | public override void Draw()
44 | {
45 | Graphics.SetColor(1, 1, 1);
46 | if (buffer == null)
47 | {
48 | Graphics.Print("No buffer available");
49 | return;
50 | }
51 |
52 | int len = buffer.FloatBuffer.Length / 8;
53 | float pad = (float)len / WindowWidth; // samples per pixels
54 |
55 | for (int x = 0; x < WindowWidth; x++)
56 | {
57 | // current sample
58 | int i = (int)Math.Round(x * pad);
59 | float y = buffer.FloatBuffer[i];
60 |
61 | // previous sample
62 | int x1 = x - 1;
63 | int i1 = (int)Math.Round((x - 1) * pad);
64 | float y1 = buffer.FloatBuffer[Math.Max(i1, 0)];
65 |
66 | // render
67 | Graphics.SetColor(Math.Abs(y), 1f - Math.Abs(y), Math.Abs(y), 1f);
68 | Graphics.Line(x1, WindowHeight / 2 + y1 * (WindowHeight / (Intensity * 2)), x, WindowHeight / 2 + y * (WindowHeight / (Intensity * 2)));
69 | }
70 |
71 | // fft
72 | Complex[] values = new Complex[Size];
73 | for (int i = 0; i < values.Length; i++)
74 | values[i] = new Complex(buffer.FloatBuffer[i], 0.0);
75 | FourierTransform.FFT(values, FourierTransform.Direction.Forward);
76 |
77 | for (int i = 0; i < Size; i++)
78 | {
79 | float v = (float)(values[i].Magnitude);
80 | //Graphics.Print(v.ToString(), 0, (i + 1) * 16);
81 | Graphics.SetColor(Math.Abs(v), 1f - Math.Abs(v), 1f - Math.Abs(v), 1f);
82 | Graphics.Rectangle(DrawMode.Fill, i * 16, WindowHeight, 16, -v * 10 * WindowHeight - 1);
83 |
84 | /*int j = Math.Max(i - 1, 0);
85 | float w = (float)(values[j].Magnitude);
86 | Graphics.Line(j, w * WindowHeight, i, v * WindowHeight);*/
87 | }
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/Audio Visualizer/FreqVisualizerMathNet.cs:
--------------------------------------------------------------------------------
1 | using Love;
2 | using NAudio.Wave;
3 | using System;
4 | using System.Numerics;
5 | using MathNet.Numerics.IntegralTransforms;
6 | using System.Collections.Generic;
7 |
8 | namespace AudioVisualizer
9 | {
10 | enum SmoothType
11 | {
12 | horizontal,
13 | vertical,
14 | both
15 | }
16 |
17 | /*
18 | * Visualizer using frequencies
19 | */
20 | class FreqVisualizerMathNet : VisualizerWindow
21 | {
22 | private WaveBuffer buffer;
23 |
24 | private static int vertical_smoothness = 3;
25 | private static int horizontal_smoothness = 1;
26 | private float size = 10;
27 |
28 | private int vis_mode = 0;
29 |
30 | private static SmoothType smoothType = SmoothType.both;
31 |
32 | private List smooth = new List();
33 |
34 | private Complex[] values;
35 |
36 | private double pre_value = 0;
37 |
38 | private double count = 64;
39 |
40 | public override void Load()
41 | {
42 | WindowTitle = "Frequency Visualizer";
43 | base.Load();
44 |
45 | // start audio capture
46 | var capture = new WasapiLoopbackCapture();
47 |
48 | capture.DataAvailable += DataAvailable;
49 |
50 | capture.RecordingStopped += (s, a) =>
51 | {
52 | capture.Dispose();
53 | };
54 |
55 | capture.StartRecording();
56 | }
57 |
58 | public void DataAvailable(object sender, WaveInEventArgs e)
59 | {
60 | buffer = new WaveBuffer(e.Buffer); // save the buffer in the class variable
61 |
62 | int len = buffer.FloatBuffer.Length / 8;
63 |
64 | // fft
65 | values = new Complex[len];
66 | for (int i = 0; i < len; i++)
67 | values[i] = new Complex(buffer.FloatBuffer[i], 0.0);
68 | Fourier.Forward(values, FourierOptions.Default);
69 |
70 | // shift array
71 | if (smoothType == SmoothType.vertical || smoothType == SmoothType.both)
72 | {
73 | smooth.Add(values);
74 | if (smooth.Count > vertical_smoothness)
75 | smooth.RemoveAt(0);
76 | }
77 | }
78 | public override void KeyPressed(KeyConstant key, Scancode scancode, bool isRepeat)
79 | {
80 | base.KeyPressed(key, scancode, isRepeat);
81 |
82 | switch (key)
83 | {
84 | case KeyConstant.Right:
85 | horizontal_smoothness++;
86 | break;
87 | case KeyConstant.Left:
88 | if (horizontal_smoothness > 1)
89 | horizontal_smoothness--;
90 | break;
91 | case KeyConstant.Down:
92 | if (vertical_smoothness > 1)
93 | {
94 | vertical_smoothness--;
95 | for (int i = 0; i < smooth.Count; i++)
96 | smooth.RemoveAt(i);
97 | }
98 | break;
99 | case KeyConstant.Up:
100 | vertical_smoothness++;
101 | for (int i = 0; i < smooth.Count; i++)
102 | smooth.RemoveAt(i);
103 | break;
104 | case KeyConstant.H:
105 | smoothType = SmoothType.horizontal;
106 | break;
107 | case KeyConstant.V:
108 | smoothType = SmoothType.vertical;
109 | break;
110 | case KeyConstant.B:
111 | smoothType = SmoothType.both;
112 | break;
113 | case KeyConstant.Number1:
114 | vis_mode = 0;
115 | break;
116 | case KeyConstant.Number2:
117 | vis_mode = 1;
118 | break;
119 | case KeyConstant.Number3:
120 | vis_mode = 2;
121 | break;
122 | case KeyConstant.Number4:
123 | vis_mode = 3;
124 | break;
125 | case KeyConstant.Number5:
126 | vis_mode = 4;
127 | break;
128 | case KeyConstant.Number6:
129 | vis_mode = 5;
130 | break;
131 | case KeyConstant.Number7:
132 | vis_mode = 6;
133 | break;
134 | case KeyConstant.Number8:
135 | vis_mode = 7;
136 | break;
137 | case KeyConstant.Number9:
138 | vis_mode = 8;
139 | break;
140 | case KeyConstant.Number0:
141 | vis_mode = 9;
142 | break;
143 | }
144 | }
145 |
146 | public double vSmooth(int i, Complex[][] s)
147 | {
148 | double value = 0;
149 |
150 | for (int v = 0; v < s.Length; v++)
151 | value += Math.Abs(s[v] != null ? s[v][i].Magnitude : 0.0);
152 |
153 | return value / s.Length;
154 | }
155 |
156 | public double MovingAverage(Complex[] v, int i)
157 | {
158 | double value = 0;
159 |
160 | for (int h = Math.Max(i - horizontal_smoothness, 0); h < Math.Min(i + horizontal_smoothness, 64); h++)
161 | value += v[h].Magnitude;
162 |
163 | return value / ((horizontal_smoothness + 1) * 2);
164 | }
165 |
166 | public double BothSmooth(int i)
167 | {
168 | var s = smooth.ToArray();
169 |
170 | double value = 0;
171 |
172 | for (int h = Math.Max(i - horizontal_smoothness, 0); h < Math.Min(i + horizontal_smoothness, 64); h++)
173 | value += vSmooth(h, s);
174 |
175 | return value / ((horizontal_smoothness + 1) * 2);
176 | }
177 |
178 | public double hSmooth(int i)
179 | {
180 | if (i > 1) {
181 | double value = values[i].Magnitude;
182 |
183 | for (int h = i - horizontal_smoothness; h <= i + horizontal_smoothness; h++)
184 | value += values[h].Magnitude;
185 |
186 | return value / ((horizontal_smoothness + 1) * 2);
187 | }
188 |
189 | return 0;
190 | }
191 |
192 | private void DrawVis(int i, double c, float size, double value)
193 | {
194 | float pre_x = 0, pre_y = 0, x = 0, y = 0;
195 |
196 | if (vis_mode == 2 || vis_mode == 3 || vis_mode == 4)
197 | {
198 | value *= 100;
199 |
200 | double n = c / (Math.PI * 2);
201 | double j = (i - 1) / n;
202 | pre_x = (float)(Math.Cos(j) * pre_value) + WindowWidth / 2;
203 | pre_y = (float)(Math.Sin(j) * pre_value) + WindowHeight / 2;
204 |
205 | j = i / n;
206 | x = (float)(Math.Cos(j) * value) + WindowWidth / 2;
207 | y = (float)(Math.Sin(j) * value) + WindowHeight / 2;
208 | }
209 | else if (vis_mode == 6)
210 | {
211 | value *= 10;
212 |
213 | double n = c / Math.PI;
214 | double j = i / n + Math.PI / 2;
215 |
216 | pre_x = (float)(Math.Cos(j) * pre_value) * 10;
217 | pre_y = (float)(Math.Sin(j) * pre_value) * -10 + WindowHeight / 2;
218 |
219 | j = (i + 1) / n + Math.PI / 2;
220 | x = (float)(Math.Cos(j) * value) * 10;
221 | y = (float)(Math.Sin(j) * value) * -10 + WindowHeight / 2;
222 | }
223 | else
224 | {
225 | value *= WindowHeight / 2;
226 | }
227 |
228 | value += BothSmooth(i - 1) + BothSmooth(i + 1);
229 | value /= 3;
230 |
231 | switch (vis_mode)
232 | {
233 | case 1:
234 | Graphics.Line(i * size - size / 2, (float)(WindowHeight - pre_value), (i + 1) * size - size / 2, (float)(WindowHeight - value));
235 | break;
236 | case 2:
237 | Graphics.Circle(DrawMode.Fill, x, y, 1);
238 | break;
239 | case 3:
240 | Graphics.Line(pre_x, pre_y, x, y);
241 | break;
242 | case 4:
243 | Graphics.SetColor((float)value / 255, (float)value / 255, (float)value / 255);
244 | Graphics.Polygon(DrawMode.Fill, pre_x, pre_y, x, y, WindowWidth / 2, WindowHeight / 2);
245 | break;
246 | case 5:
247 | Graphics.SetColor(1f - i / 64f, i / 64f, 0, 1);
248 | Graphics.Arc(DrawMode.Fill, WindowWidth / 2, WindowHeight / 2, 256, 0, (float)value / 255);
249 | break;
250 | case 6:
251 | Graphics.Line(pre_x + WindowWidth / 2, pre_y, x + WindowWidth / 2, y);
252 | Graphics.Line(-pre_x + WindowWidth / 2, pre_y, -x + WindowWidth / 2, y);
253 | break;
254 | case 7:
255 | for (float l = 0; l < value + size * 0.75f; l += size * 0.75f)
256 | Graphics.Rectangle(DrawMode.Fill, i * size, WindowHeight - l, size * 0.95f, size / 2);
257 | break;
258 | case 8:
259 | for (float l = 0; l < value; l++)
260 | {
261 | float u = l / WindowHeight;
262 | Graphics.SetColor(u, 1-u, 0);
263 | Graphics.Line(i * size, WindowHeight - l, (i + 1) * size, WindowHeight - l);
264 | }
265 | break;
266 | default:
267 | Graphics.Rectangle(DrawMode.Fill, i * size, WindowHeight, size, (float)-value);
268 | break;
269 | }
270 | pre_value = value;
271 | }
272 |
273 | public override void Draw()
274 | {
275 | Graphics.SetColor(1, 1, 1);
276 | if (buffer == null)
277 | {
278 | Graphics.Print("No buffer available");
279 | return;
280 | }
281 |
282 | Graphics.Print("FPS:" + Timer.GetFPS() + "\n1-8: visualizer mode\nLeft/right arrows: horizontal smoothness strength\n Current: " + horizontal_smoothness + "\nUp/down arrows: vertical smoothness strength\n Current: " + vertical_smoothness, 0, 0);
283 |
284 | size = WindowWidth / 64;
285 |
286 | if (smoothType == SmoothType.vertical)
287 | {
288 | var s = smooth.ToArray();
289 | // vertical smoothness
290 | for (int i = 0; i < count; i++)
291 | {
292 | double value = 0;
293 | for (int v = 0; v < s.Length; v++)
294 | value += Math.Abs(s[v] != null ? s[v][i].Magnitude : 0.0);
295 | value /= s.Length;
296 |
297 | DrawVis(i, count, size, value);
298 | }
299 | }
300 | else if (smoothType == SmoothType.horizontal)
301 | {
302 | for (int i = 0; i < count; i++)
303 | {
304 | double value = 0;
305 | for (int h = Math.Max(i - horizontal_smoothness, 0); h < Math.Min(i + horizontal_smoothness, 64); h++)
306 | value += values[h].Magnitude;
307 | value /= ((horizontal_smoothness + 1) * 2);
308 |
309 | DrawVis(i, count, size, value);
310 | }
311 | }
312 | else if (smoothType == SmoothType.both)
313 | {
314 | for (int i = 0; i < count; i++)
315 | {
316 | double value = BothSmooth(i);
317 | DrawVis(i, count, size, value);
318 | }
319 | }
320 | }
321 | }
322 | }
323 |
--------------------------------------------------------------------------------
/Audio Visualizer/FreqVisualizerNAudio.cs:
--------------------------------------------------------------------------------
1 | using Love;
2 | using NAudio.Wave;
3 | using System;
4 |
5 | namespace AudioVisualizer
6 | {
7 | /*
8 | * Visualizer using frequencies
9 | */
10 | class FreqVisualizerNAudio : VisualizerWindow
11 | {
12 | private WaveBuffer buffer;
13 |
14 | private int M = 6;
15 |
16 | public override void Load()
17 | {
18 | WindowTitle = "Frequency Visualizer";
19 | base.Load();
20 |
21 | // start audio capture
22 | var capture = new WasapiLoopbackCapture();
23 |
24 | capture.DataAvailable += DataAvailable;
25 |
26 | capture.RecordingStopped += (s, a) =>
27 | {
28 | capture.Dispose();
29 | };
30 |
31 | capture.StartRecording();
32 | }
33 |
34 | public void DataAvailable(object sender, WaveInEventArgs e)
35 | {
36 | buffer = new WaveBuffer(e.Buffer); // save the buffer in the class variable
37 | }
38 |
39 | public override void Draw()
40 | {
41 | Graphics.SetColor(1, 1, 1);
42 | if (buffer == null)
43 | {
44 | Graphics.Print("No buffer available");
45 | return;
46 | }
47 |
48 | int len = buffer.FloatBuffer.Length / 8;
49 |
50 | // fft
51 | NAudio.Dsp.Complex[] values = new NAudio.Dsp.Complex[len];
52 | for (int i = 0; i < len; i++)
53 | {
54 | values[i].Y = 0;
55 | values[i].X = buffer.FloatBuffer[i];
56 | }
57 | NAudio.Dsp.FastFourierTransform.FFT(true, M, values);
58 |
59 | float size = (float)WindowWidth / ((float)Math.Pow(2, M) / 2);
60 |
61 | for (int i = 1; i < Math.Pow(2, M) / 2; i++)
62 | {
63 | //Graphics.Print(i.ToString() + ": " + values[i].X.ToString("N2") + " i " + (values[i].Y + 0.50f).ToString("N2"), 0, (i + 1) * 16);
64 | Graphics.Rectangle(DrawMode.Fill, (i - 1) * size, WindowHeight / 2, size, -Math.Abs(values[i].X) * (WindowHeight / 2) * 10);
65 | }
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/Audio Visualizer/Oscilloscope.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Love;
3 | using NAudio.Wave;
4 |
5 | namespace AudioVisualizer
6 | {
7 | /*
8 | * Oscilloscope made by saving the WaveBuffer
9 | * as a class variable
10 | * Has a better rendering than Oscilloscope3
11 | */
12 | class Oscilloscope : VisualizerWindow
13 | {
14 | private WaveBuffer buffer;
15 |
16 | private int Intensity = 2;
17 | private int Zoom = 8;
18 |
19 | public override void Load()
20 | {
21 | WindowTitle = "Audio Oscilloscope";
22 | base.Load();
23 |
24 | // start audio capture
25 | var capture = new WasapiLoopbackCapture();
26 |
27 | capture.DataAvailable += DataAvailable;
28 |
29 | capture.RecordingStopped += (s, a) =>
30 | {
31 | capture.Dispose();
32 | };
33 |
34 | capture.StartRecording();
35 | }
36 |
37 | void DataAvailable(object sender, WaveInEventArgs e)
38 | {
39 | buffer = new WaveBuffer(e.Buffer); // save the buffer in the class variable
40 | }
41 |
42 | public override void KeyPressed(KeyConstant key, Scancode scancode, bool isRepeat)
43 | {
44 | base.KeyPressed(key, scancode, isRepeat);
45 |
46 | if (key == KeyConstant.Right) Zoom += 1;
47 | if (key == KeyConstant.Left) Zoom = Math.Max(Zoom - 1, 1);
48 | }
49 |
50 | public override void WheelMoved(int x, int y)
51 | {
52 | Intensity = Math.Max(Intensity - y, 1);
53 | }
54 |
55 | public override void Draw()
56 | {
57 | Graphics.SetColor(1, 1, 1);
58 | if (buffer == null)
59 | {
60 | Graphics.Print("No buffer available");
61 | return;
62 | }
63 |
64 | Graphics.Print("Controls:\nMouse wheel: Intensity\nLeft/Right arrows: Zoom\nf: Toggle fullscreen\nescape: Quit", 0, WindowHeight - 14 * 5);
65 |
66 | int len = buffer.FloatBuffer.Length / Zoom;
67 |
68 | if (len < WindowWidth && Zoom > 0)
69 | {
70 | Zoom -= 1;
71 | Graphics.Print("An error occured, please wait");
72 | return;
73 | } else if (Zoom <= 0)
74 | Graphics.Print("Zoom is invalid");
75 |
76 | int pad = len / WindowWidth; // samples per pixels
77 |
78 | Graphics.Print(
79 | "Length of buffer: " + buffer.FloatBuffer.Length.ToString() + "\n" +
80 | "Length: " + len + "\n" +
81 | "Window width: " + WindowWidth + "\n" +
82 | "Samples per pixels: " + pad.ToString() + "\n" +
83 | "Intensity: " + Intensity.ToString() + "\n" +
84 | "Zoom: " + Zoom.ToString()
85 | );
86 |
87 | for (int i = 0; i < len; i += pad)
88 | {
89 | // current sample
90 | int x = i;
91 | float y = buffer.FloatBuffer[i];
92 |
93 | // previous sample
94 | int x1 = Math.Max(i - pad, 0);
95 | float y1 = buffer.FloatBuffer[Math.Max(i - pad, 0)];
96 |
97 | // render
98 | Graphics.SetColor(Math.Abs(y), 1f - Math.Abs(y), Math.Abs(y), 1f);
99 | Graphics.Line(x1, WindowHeight / 2 + y1 * (WindowHeight / (Intensity * 2)), x, WindowHeight / 2 + y * (WindowHeight / (Intensity * 2)));
100 | }
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/Audio Visualizer/OscilloscopeBWP.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Love;
3 | using NAudio.Wave;
4 |
5 | namespace AudioVisualizer
6 | {
7 | /*
8 | * Oscilloscope using a BufferedWaveProvider
9 | */
10 | class OscilloscopeBWP : Scene
11 | {
12 | public BufferedWaveProvider bwp;
13 | private int BUFFERSIZE = 4800;
14 |
15 | public int SIZE = 16;
16 |
17 | public override void Load()
18 | {
19 | WindowSettings mode = Window.GetMode();
20 | mode.resizable = true;
21 | Window.SetMode(mode);
22 |
23 | // audio stuff
24 | var capture = new WasapiLoopbackCapture();
25 |
26 | bwp = new BufferedWaveProvider(capture.WaveFormat);
27 | bwp.BufferLength = BUFFERSIZE * 2;
28 |
29 | bwp.DiscardOnBufferOverflow = true;
30 |
31 | capture.DataAvailable += DataAvailable;
32 |
33 | capture.RecordingStopped += (s, a) =>
34 | {
35 | capture.Dispose();
36 | };
37 |
38 | capture.StartRecording();
39 | }
40 |
41 | void DataAvailable(object sender, WaveInEventArgs e)
42 | {
43 | bwp.AddSamples(e.Buffer, 0, e.BytesRecorded);
44 | }
45 |
46 | public override void Draw()
47 | {
48 | byte[] b = new byte[BUFFERSIZE];
49 | bwp.Read(b, 0, BUFFERSIZE);
50 |
51 | WaveBuffer buffer = new WaveBuffer(b);
52 |
53 | int width = Graphics.GetWidth() * 2;
54 | int height = Graphics.GetHeight();
55 | int len = BUFFERSIZE;
56 | int pad = len / width;
57 |
58 | for (int index = 0; index < len; index += pad)
59 | {
60 | int x = index / pad;
61 | float y = buffer.FloatBuffer[index];
62 |
63 | int x1 = Math.Max(index - 1, 0) / pad;
64 | float y1 = buffer.FloatBuffer[Math.Max(index - 1, 0)];
65 |
66 | Graphics.SetColor(Math.Abs(y), 1f - Math.Abs(y), Math.Abs(y), 1f);
67 | Graphics.Line(x1, height / 2 + y1 * (height / 2), x, height / 2 + y * (height / 2));
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Audio Visualizer/OscilloscopeImproved.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Love;
3 | using NAudio.Wave;
4 |
5 | namespace AudioVisualizer
6 | {
7 | /*
8 | * Oscilloscope made by saving the WaveBuffer
9 | * as a class variable
10 | * Same as oscilloscope but with better precision
11 | */
12 | class OscilloscopeImproved : VisualizerWindow
13 | {
14 | private WaveBuffer buffer;
15 |
16 | private int Intensity = 2;
17 | private int Zoom = 8;
18 |
19 | public override void Load()
20 | {
21 | WindowTitle = "Audio Oscilloscope";
22 | base.Load();
23 |
24 | // start audio capture
25 | var capture = new WasapiLoopbackCapture();
26 |
27 | capture.DataAvailable += DataAvailable;
28 |
29 | capture.RecordingStopped += (s, a) =>
30 | {
31 | capture.Dispose();
32 | };
33 |
34 | capture.StartRecording();
35 | }
36 |
37 | public void DataAvailable(object sender, WaveInEventArgs e)
38 | {
39 | buffer = new WaveBuffer(e.Buffer); // save the buffer in the class variable
40 | }
41 |
42 | public override void KeyPressed(KeyConstant key, Scancode scancode, bool isRepeat)
43 | {
44 | base.KeyPressed(key, scancode, isRepeat);
45 |
46 | switch (key)
47 | {
48 | case KeyConstant.Right:
49 | Zoom += 1;
50 | break;
51 | case KeyConstant.Left:
52 | Zoom = Math.Max(Zoom - 1, 1);
53 | break;
54 | case KeyConstant.R:
55 | Zoom = 8;
56 | Intensity = 2;
57 | break;
58 | }
59 | }
60 |
61 | public override void WheelMoved(int x, int y)
62 | {
63 | Intensity = Math.Max(Intensity - y, 1);
64 | }
65 |
66 | public override void Draw()
67 | {
68 | Graphics.SetColor(1, 1, 1);
69 | if (buffer == null)
70 | {
71 | Graphics.Print("No buffer available");
72 | return;
73 | }
74 |
75 | Graphics.Print("Controls:\nMouse wheel: Intensity\nLeft/Right arrows: Zoom\nf: Toggle fullscreen\nr: Reset zoom & intensity\nescape: Quit", 0, WindowHeight - 14 * 6);
76 |
77 | int len = buffer.FloatBuffer.Length / Zoom;
78 |
79 | if (Zoom <= 0)
80 | Graphics.Print("Zoom is invalid");
81 |
82 | float pad = (float)len / 2 / WindowWidth; // samples per pixels
83 |
84 | Graphics.Print(
85 | "Length of buffer: " + buffer.FloatBuffer.Length.ToString() + "\n" +
86 | "Length: " + len + "\n" +
87 | "Window width: " + WindowWidth + "\n" +
88 | "Samples per pixels: " + pad.ToString("N2") + "\n" +
89 | "Intensity: " + Intensity.ToString() + "\n" +
90 | "Zoom: " + Zoom.ToString()
91 | );
92 |
93 | for (int x = 0; x < WindowWidth; x++)
94 | {
95 | // current sample
96 | int i = (int)Math.Round(x * pad);
97 | float y = buffer.FloatBuffer[i];
98 |
99 | // previous sample
100 | int x1 = x - 1;
101 | int i1 = (int)Math.Round((x - 1) * pad);
102 | float y1 = buffer.FloatBuffer[Math.Max(i1, 0)];
103 |
104 | // render
105 | Graphics.SetColor(Math.Abs(y), 1f - Math.Abs(y), Math.Abs(y), 1f);
106 | Graphics.Line(x1, WindowHeight / 2 + y1 * (WindowHeight / (Intensity * 2)), x, WindowHeight / 2 + y * (WindowHeight / (Intensity * 2)));
107 | }
108 | }
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/Audio Visualizer/OscilloscopeMusicVisualizer.cs:
--------------------------------------------------------------------------------
1 | using Love;
2 | using NAudio.Wave;
3 | using NAudio.Wave.SampleProviders;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Text;
7 |
8 | namespace AudioVisualizer
9 | {
10 | class OscilloscopeMusicVisualizer : VisualizerWindow
11 | {
12 | private int Zoom = 100;
13 | private int Resolution = 2048;
14 |
15 | private BufferedWaveProvider[] stereo = new BufferedWaveProvider[2];
16 |
17 | public override void Load()
18 | {
19 | WindowTitle = "Audio Oscilloscope";
20 | base.Load();
21 |
22 | // start audio capture
23 | var capture = new WasapiLoopbackCapture();
24 | for (int i = 0; i < 2; i++)
25 | {
26 | stereo[i] = new BufferedWaveProvider(capture.WaveFormat);
27 | stereo[i].BufferLength = 2048;
28 | stereo[i].DiscardOnBufferOverflow = true;
29 | }
30 |
31 | capture.DataAvailable += DataAvailable;
32 |
33 | capture.RecordingStopped += (s, a) =>
34 | {
35 | capture.Dispose();
36 | };
37 |
38 | capture.StartRecording();
39 | }
40 |
41 | public void DataAvailable(object sender, WaveInEventArgs e)
42 | {
43 | if (e.BytesRecorded != 0)
44 | {
45 | int offset = 0;
46 | while (offset < e.BytesRecorded)
47 | {
48 | for (int n = 0; n < ((WasapiLoopbackCapture)sender).WaveFormat.Channels; n++)
49 | {
50 | stereo[n].AddSamples(e.Buffer, offset, 4);
51 | offset += 4;
52 | }
53 | }
54 | }
55 | }
56 |
57 | public override void WheelMoved(int x, int y)
58 | {
59 | Zoom = Math.Max(Zoom + y, 1);
60 | }
61 |
62 | public override void Draw()
63 | {
64 | Graphics.Print("Zoom: " + Zoom.ToString());
65 |
66 | byte[] buffer1 = new byte[Resolution];
67 | stereo[0].Read(buffer1, 0, buffer1.Length);
68 | float[] left = new WaveBuffer(buffer1).FloatBuffer;
69 |
70 | byte[] buffer2 = new byte[Resolution];
71 | stereo[1].Read(buffer2, 0, buffer2.Length);
72 | float[] right = new WaveBuffer(buffer2).FloatBuffer;
73 |
74 | for (int i = 0; i < Resolution / 4; i++)
75 | {
76 | int j = Math.Max(i - 1, 0);
77 | Graphics.Line(WindowWidth / 2 + left[j] * Zoom, WindowHeight / 2 + right[j] * -Zoom, WindowWidth / 2 + left[i] * Zoom, WindowHeight / 2 + right[i] * -Zoom);
78 | }
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/Audio Visualizer/OscilloscopeMusicVisualizerImproved.cs:
--------------------------------------------------------------------------------
1 | using Love;
2 | using NAudio.Wave;
3 | using NAudio.Wave.SampleProviders;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Text;
7 |
8 | namespace AudioVisualizer
9 | {
10 | class OscilloscopeMusicVisualizerImproved : VisualizerWindow
11 | {
12 | private int Zoom = 100;
13 | private int Resolution = 2048;
14 |
15 | private int BufferLife = 1;
16 |
17 | private BufferedWaveProvider[] stereo = new BufferedWaveProvider[2];
18 | private List audio = new List();
19 | private List BufferTimes = new List();
20 |
21 | public override void Load()
22 | {
23 | WindowTitle = "Audio Oscilloscope";
24 | base.Load();
25 |
26 | // start audio capture
27 | var capture = new WasapiLoopbackCapture();
28 | for (int i = 0; i < 2; i++)
29 | {
30 | stereo[i] = new BufferedWaveProvider(capture.WaveFormat);
31 | stereo[i].BufferLength = 2048;
32 | stereo[i].DiscardOnBufferOverflow = true;
33 | }
34 |
35 | capture.DataAvailable += DataAvailable;
36 |
37 | capture.RecordingStopped += (s, a) =>
38 | {
39 | capture.Dispose();
40 | };
41 |
42 | capture.StartRecording();
43 | }
44 |
45 | public void DataAvailable(object sender, WaveInEventArgs e)
46 | {
47 | if (e.BytesRecorded != 0)
48 | {
49 | int offset = 0;
50 | while (offset < e.BytesRecorded)
51 | {
52 | for (int n = 0; n < ((WasapiLoopbackCapture)sender).WaveFormat.Channels; n++)
53 | {
54 | stereo[n].AddSamples(e.Buffer, offset, 4);
55 | offset += 4;
56 | }
57 | }
58 |
59 | WaveBuffer[] a = new WaveBuffer[2];
60 |
61 | byte[] buffer1 = new byte[Resolution];
62 | byte[] buffer2 = new byte[Resolution];
63 |
64 | stereo[0].Read(buffer1, 0, buffer1.Length);
65 | stereo[1].Read(buffer2, 0, buffer2.Length);
66 |
67 | a[0] = new WaveBuffer(buffer1);
68 | a[1] = new WaveBuffer(buffer2);
69 |
70 | audio.Add(a);
71 | }
72 | }
73 |
74 | public override void Update(float dt)
75 | {
76 | audio.ForEach((a) =>
77 | {
78 | int index = audio.IndexOf(a);
79 |
80 | Console.WriteLine(BufferTimes[index]);
81 |
82 | BufferTimes[index] += dt;
83 |
84 | if (BufferTimes[index] >= BufferLife)
85 | {
86 | audio.RemoveAt(index);
87 | BufferTimes[index] = 0;
88 | }
89 | });
90 | }
91 |
92 | public override void WheelMoved(int x, int y)
93 | {
94 | Zoom = Math.Max(Zoom + y, 1);
95 | }
96 |
97 | public override void Draw()
98 | {
99 | Graphics.Print("Zoom: " + Zoom.ToString());
100 |
101 | audio.ForEach((a) =>
102 | {
103 | int index = audio.IndexOf(a);
104 | float color = (index - audio.Count) / audio.Count;
105 |
106 | //Graphics.Print("Index: " + index.ToString() + "\nLife: " + BufferTimes[index].ToString("N2"), 0, (index + 1) * 14);
107 |
108 | for (int i = 0; i < a[0].FloatBuffer.Length / 4; i++)
109 | {
110 | int j = Math.Max(i - 1, 0);
111 | Graphics.Line(WindowWidth / 2 + a[0].FloatBuffer[j] * Zoom, WindowHeight / 2 + a[1].FloatBuffer[j] * Zoom, WindowWidth / 2 + a[0].FloatBuffer[i] * Zoom, WindowHeight / 2 + a[1].FloatBuffer[i] * Zoom);
112 | }
113 | });
114 | }
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/Audio Visualizer/Program.cs:
--------------------------------------------------------------------------------
1 | using Love;
2 |
3 | namespace AudioVisualizer
4 | {
5 | class Program
6 | {
7 | static void Main(string[] args)
8 | {
9 | Boot.Run(new FreqVisualizerMathNet());
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Audio Visualizer/VisualizerWindow.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Love;
3 |
4 | namespace AudioVisualizer
5 | {
6 | /*
7 | * Just a base window using Love2D to use
8 | * with the visualizer
9 | */
10 | class VisualizerWindow : Scene
11 | {
12 | public int WindowWidth;
13 | public int WindowHeight;
14 |
15 | public string WindowTitle;
16 |
17 | public override void Load()
18 | {
19 | WindowSettings mode = Window.GetMode();
20 | mode.resizable = true;
21 | Window.SetMode(mode);
22 |
23 | Window.SetTitle(WindowTitle);
24 |
25 | WindowWidth = Graphics.GetWidth();
26 | WindowHeight = Graphics.GetHeight();
27 | }
28 |
29 | public override void WindowResize(int w, int h)
30 | {
31 | WindowWidth = w;
32 | WindowHeight = h;
33 | }
34 |
35 | public override void KeyPressed(KeyConstant key, Scancode scancode, bool isRepeat)
36 | {
37 | if (key == KeyConstant.F) Window.SetFullscreen(!Window.GetFullscreen());
38 | if (key == KeyConstant.Escape) Event.Quit();
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Quozul
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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quozul/Audio-Visualizer/2bfd7e44e5a69e1d84bfc010e6b749f25a25f2d9/README.md
--------------------------------------------------------------------------------