This repository has been archived by the owner on Jul 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathMusicPlayer.cs
87 lines (70 loc) · 2.41 KB
/
MusicPlayer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
79
80
81
82
83
84
85
86
87
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using System.ComponentModel.Composition;
using WinHuePluginModule;
using System.Drawing;
using System.Windows;
using System.Windows.Input;
using Un4seen.Bass;
using Un4seen.Bass.Misc;
using HueLib_base;
using System.Threading;
namespace MusicPlayer
{
[Export(typeof(IWinHuePluginModule))]
class MusicPlayer : IWinHuePluginModule
{
[Import(typeof (IWinhuePluginHost))]
private IWinhuePluginHost Host;
public bool? ShowSettingsForm()
{
SettingsForm sf = new SettingsForm();
sf.Owner = Application.Current.MainWindow;
sf.ShowDialog();
return true;
}
private RECORDPROC _myRecProc;
public void Start()
{
Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
Bass.BASS_RecordInit(-1);
_myRecProc = new RECORDPROC(MyRecording);
int inputsource = 0;
int settings = 0;
float vol = 0;
while (settings != -1)
{
settings = Bass.BASS_RecordGetInput(inputsource,ref vol);
if (Bass.BASS_RecordGetInputName(inputsource) == "Speakers")
{
break;
}
inputsource++;
}
Bass.BASS_RecordSetInput(inputsource, BASSInput.BASS_INPUT_ON, 0.5F);
int recChannel = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE, 50, _myRecProc, IntPtr.Zero);
Bass.BASS_ChannelPlay(recChannel, false);
}
private bool MyRecording(int handle, IntPtr buffer, int length, IntPtr user)
{
float[] fft = new float[length];
Bass.BASS_ChannelGetData(handle, fft, length);
// foreach()
// int hz = Utils.FFTIndex2Frequency(1, length, 44100);
// Console.WriteLine(hz);
return true;
}
public void Stop()
{
// throw new NotImplementedException();
}
public Bitmap pluginIcon => Properties.Resources.pluginicon;
public string pluginName => "Music Player";
public string pluginDesc => "Playing music is reflected in the lights.";
public string pluginAuth => "Pascal Pharand";
}
}