├── .gitignore ├── README.html ├── README.md ├── SoundCenSe GTK ├── ArrowDown.png ├── ArrowUp.png ├── DisableSound 15x15.png ├── FastForward.png ├── Misc │ ├── Enums │ │ ├── Loop.cs │ │ ├── RunState.cs │ │ └── Threshold.cs │ ├── Events │ │ ├── ChannelFastForwardEventArgs.cs │ │ ├── ChannelMuteEventArgs.cs │ │ ├── DisableSoundEventArgs.cs │ │ ├── DownloadFinishedEventArgs.cs │ │ ├── DwarfFortressRunningEventArgs.cs │ │ ├── DwarfFortressStoppedEventArgs.cs │ │ ├── GamelogEventArgs.cs │ │ ├── RestartSoundLoopEventArgs.cs │ │ ├── SoundFinishedEventArgs.cs │ │ ├── SoundPlayingEventArgs.cs │ │ ├── StartDownloadEventArgs.cs │ │ ├── UpdateFinishedEventArgs.cs │ │ ├── VolumeChangedEventArgs.cs │ │ ├── XMLParseDoneEventArgs.cs │ │ └── XMLParseProgressEventArgs.cs │ ├── Interfaces │ │ ├── DownloadResult.cs │ │ ├── IDownloadEntry.cs │ │ ├── IPlayerManager.cs │ │ ├── IPlaylistParser.cs │ │ ├── ISound.cs │ │ ├── ISoundFile.cs │ │ └── ISoundSoundFile.cs │ ├── Misc.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ └── StringExtension.cs ├── Mute.png ├── Program.ico ├── SignalGreen.png ├── SignalRed.png ├── SoundCenSeGTK.sln ├── SoundCenSeGTK │ ├── Config.cs │ ├── Configuration.json │ ├── Configuration │ │ ├── ChannelData.cs │ │ ├── ConfigurationData.cs │ │ ├── Sounds │ │ │ ├── Attribution.cs │ │ │ ├── Playlist.cs │ │ │ ├── Playlist │ │ │ │ ├── M3UParser.cs │ │ │ │ └── PLSParser.cs │ │ │ ├── Sound.cs │ │ │ ├── SoundFile.cs │ │ │ └── SoundsXML.cs │ │ └── XMLExtensions.cs │ ├── FmodSystem.cs │ ├── Input │ │ └── LogFileListener.cs │ ├── MainWindow.cs │ ├── MessageBox.cs │ ├── NLog.config │ ├── NLog.xsd │ ├── Output │ │ ├── DummyPlayerManager.cs │ │ ├── DummySoundProcessor.cs │ │ ├── SoundProcessor.cs │ │ ├── SoundSoundFile.cs │ │ ├── fmodChannelPool.cs │ │ ├── fmodChannelSound.cs │ │ └── fmodPlayer.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SoundCenSeGTK.csproj │ ├── Utility │ │ ├── DownloadEntry.cs │ │ ├── PackDownloader.cs │ │ └── XML │ │ │ ├── DirectoryData.cs │ │ │ └── UpdateParser.cs │ ├── fmod.config │ ├── fmod.cs │ ├── fmod.dll │ ├── fmod.png │ ├── fmod_dsp.cs │ ├── fmod_errors.cs │ ├── fmodstudio.dll │ ├── gtk-gui │ │ ├── SoundCenSeGTK.MainWindow.cs │ │ ├── generated.cs │ │ └── gui.stetic │ ├── libfmod.dylib │ ├── libfmod.so │ ├── libfmodstudio.dylib │ ├── manifest.json │ └── packages.config ├── SoundCenSeGUI │ ├── MyClass.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SoundCenSeGUI.csproj │ ├── SoundDisabler.cs │ ├── SoundPanel.cs │ ├── SoundPanelEntry.cs │ └── gtk-gui │ │ ├── SoundCenSeGUI.SoundDisabler.cs │ │ ├── SoundCenSeGUI.SoundPanelEntry.cs │ │ ├── generated.cs │ │ └── gui.stetic └── buildOSX.sh ├── SoundCenSe WinForms ├── ArrowDown.png ├── ArrowUp.png ├── DisableSound 15x15.png ├── FastForward.png ├── LICENSE ├── Mute.png ├── Program.ico ├── SoundCenSe.sln └── SoundCenSe │ ├── App.config │ ├── Config.cs │ ├── Configuration.json │ ├── Configuration │ ├── ChannelData.cs │ ├── ConfigurationData.cs │ ├── Constants.cs │ ├── Sounds │ │ ├── Attribution.cs │ │ ├── Playlist │ │ │ ├── IPlaylistParser.cs │ │ │ ├── M3UParser.cs │ │ │ └── PLSParser.cs │ │ ├── RepeatSound.cs │ │ ├── Sound.cs │ │ ├── SoundFile.cs │ │ └── SoundsXML.cs │ └── XmlExtensions.cs │ ├── Enums │ ├── Loop.cs │ └── Threshold.cs │ ├── Events │ ├── ChannelFastForwardEventArgs.cs │ ├── ChannelMuteEventArgs.cs │ ├── ChannelVolumeEventArgs.cs │ ├── DisableSoundEventArgs.cs │ ├── DownloadFinishedEventArgs.cs │ ├── DwarfFortressRunningEventArgs.cs │ ├── DwarfFortressStoppedEventArgs.cs │ ├── GamelogEventArgs.cs │ ├── InitProgressBarEventArgs.cs │ ├── RestartSoundLoopEventArgs.cs │ ├── SoundFinishedEventArgs.cs │ ├── SoundPlayingEventArgs.cs │ ├── StartDownloadEventArgs.cs │ ├── UpdateFinishedEventArgs.cs │ ├── XMLParseDoneEventArgs.cs │ └── XMLParseProgressEventArgs.cs │ ├── FmodSystem.cs │ ├── GUI │ ├── SoundDisabler.Designer.cs │ ├── SoundDisabler.cs │ ├── SoundDisabler.resx │ ├── SoundPanel.Designer.cs │ ├── SoundPanel.cs │ ├── SoundPanel.resx │ ├── SoundPanelEntry.Designer.cs │ ├── SoundPanelEntry.cs │ ├── SoundPanelEntry.resx │ └── ToolStripSignal.cs │ ├── Input │ └── LogFileListener.cs │ ├── Interfaces │ ├── IPlayerManager.cs │ └── IStoppable.cs │ ├── NLog.config │ ├── NLog.xsd │ ├── Output │ ├── DummyPlayerManager.cs │ ├── DummySoundProcessor.cs │ └── SoundProcessor.cs │ ├── Program.cs │ ├── Program.ico │ ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings │ ├── Resources │ ├── ArrowDown.png │ ├── ArrowUp.png │ ├── DisableSound 15x15.png │ ├── FastForward.png │ ├── FastForwardImg.bmp │ └── Mute.png │ ├── SoundCenSe.csproj │ ├── SoundCenSeForm.Designer.cs │ ├── SoundCenSeForm.cs │ ├── SoundCenSeForm.resx │ ├── Utility │ ├── DwarfFortressAware.cs │ ├── ISynchronizeInvokeExtension.cs │ ├── SFXQueue.cs │ ├── StringExtension.cs │ └── Updater │ │ ├── DownloadEntry.cs │ │ ├── DownloadResult.cs │ │ ├── PackDownloader.cs │ │ └── XML │ │ ├── DirectoryData.cs │ │ └── UpdateParser.cs │ ├── fmod.cs │ ├── fmod.dll │ ├── fmodInternal │ ├── SoundSoundFile.cs │ ├── fmodChannelPool.cs │ ├── fmodChannelSound.cs │ └── fmodPlayer.cs │ ├── fmod_dsp.cs │ ├── fmod_errors.cs │ ├── fmodstudio.dll │ └── packages.config └── fmod.png /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | *.VC.VC.opendb 85 | 86 | # Visual Studio profiler 87 | *.psess 88 | *.vsp 89 | *.vspx 90 | *.sap 91 | 92 | # TFS 2012 Local Workspace 93 | $tf/ 94 | 95 | # Guidance Automation Toolkit 96 | *.gpState 97 | 98 | # ReSharper is a .NET coding add-in 99 | _ReSharper*/ 100 | *.[Rr]e[Ss]harper 101 | *.DotSettings.user 102 | 103 | # JustCode is a .NET coding add-in 104 | .JustCode 105 | 106 | # TeamCity is a build add-in 107 | _TeamCity* 108 | 109 | # DotCover is a Code Coverage Tool 110 | *.dotCover 111 | 112 | # NCrunch 113 | _NCrunch_* 114 | .*crunch*.local.xml 115 | nCrunchTemp_* 116 | 117 | # MightyMoose 118 | *.mm.* 119 | AutoTest.Net/ 120 | 121 | # Web workbench (sass) 122 | .sass-cache/ 123 | 124 | # Installshield output folder 125 | [Ee]xpress/ 126 | 127 | # DocProject is a documentation generator add-in 128 | DocProject/buildhelp/ 129 | DocProject/Help/*.HxT 130 | DocProject/Help/*.HxC 131 | DocProject/Help/*.hhc 132 | DocProject/Help/*.hhk 133 | DocProject/Help/*.hhp 134 | DocProject/Help/Html2 135 | DocProject/Help/html 136 | 137 | # Click-Once directory 138 | publish/ 139 | 140 | # Publish Web Output 141 | *.[Pp]ublish.xml 142 | *.azurePubxml 143 | # TODO: Comment the next line if you want to checkin your web deploy settings 144 | # but database connection strings (with potential passwords) will be unencrypted 145 | *.pubxml 146 | *.publishproj 147 | 148 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 149 | # checkin your Azure Web App publish settings, but sensitive information contained 150 | # in these scripts will be unencrypted 151 | PublishScripts/ 152 | 153 | # NuGet Packages 154 | *.nupkg 155 | # The packages folder can be ignored because of Package Restore 156 | **/packages/* 157 | # except build/, which is used as an MSBuild target. 158 | !**/packages/build/ 159 | # Uncomment if necessary however generally it will be regenerated when needed 160 | #!**/packages/repositories.config 161 | # NuGet v3's project.json files produces more ignoreable files 162 | *.nuget.props 163 | *.nuget.targets 164 | 165 | # Microsoft Azure Build Output 166 | csx/ 167 | *.build.csdef 168 | 169 | # Microsoft Azure Emulator 170 | ecf/ 171 | rcf/ 172 | 173 | # Windows Store app package directories and files 174 | AppPackages/ 175 | BundleArtifacts/ 176 | Package.StoreAssociation.xml 177 | _pkginfo.txt 178 | 179 | # Visual Studio cache files 180 | # files ending in .cache can be ignored 181 | *.[Cc]ache 182 | # but keep track of directories ending in .cache 183 | !*.[Cc]ache/ 184 | 185 | # Others 186 | ClientBin/ 187 | ~$* 188 | *~ 189 | *.dbmdl 190 | *.dbproj.schemaview 191 | *.pfx 192 | *.publishsettings 193 | node_modules/ 194 | orleans.codegen.cs 195 | 196 | # Since there are multiple workflows, uncomment next line to ignore bower_components 197 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 198 | #bower_components/ 199 | 200 | # RIA/Silverlight projects 201 | Generated_Code/ 202 | 203 | # Backup & report files from converting an old project file 204 | # to a newer Visual Studio version. Backup files are not needed, 205 | # because we have git ;-) 206 | _UpgradeReport_Files/ 207 | Backup*/ 208 | UpgradeLog*.XML 209 | UpgradeLog*.htm 210 | 211 | # SQL Server files 212 | *.mdf 213 | *.ldf 214 | 215 | # Business Intelligence projects 216 | *.rdl.data 217 | *.bim.layout 218 | *.bim_*.settings 219 | 220 | # Microsoft Fakes 221 | FakesAssemblies/ 222 | 223 | # GhostDoc plugin setting file 224 | *.GhostDoc.xml 225 | 226 | # Node.js Tools for Visual Studio 227 | .ntvs_analysis.dat 228 | 229 | # Visual Studio 6 build log 230 | *.plg 231 | 232 | # Visual Studio 6 workspace options file 233 | *.opt 234 | 235 | # Visual Studio LightSwitch build output 236 | **/*.HTMLClient/GeneratedArtifacts 237 | **/*.DesktopClient/GeneratedArtifacts 238 | **/*.DesktopClient/ModelManifest.xml 239 | **/*.Server/GeneratedArtifacts 240 | **/*.Server/ModelManifest.xml 241 | _Pvt_Extensions 242 | 243 | # Paket dependency manager 244 | .paket/paket.exe 245 | paket-files/ 246 | 247 | # FAKE - F# Make 248 | .fake/ 249 | 250 | # JetBrains Rider 251 | .idea/ 252 | *.sln.iml 253 | -------------------------------------------------------------------------------- /README.html: -------------------------------------------------------------------------------- 1 | 

SoundCenSe v1.4.4

2 |

SoundCenSe is a audio engine for Dwarf Fortress based on ZweiStein's SoundSense written in c#/gtk.

3 |

System requirements:

4 |

Windows:

5 | 10 |

If it doesn't seem to start, please check the Log.txt, there might be clues to what is missing.

11 |

Linux:

12 | 16 |

Don't know for sure for OSX, but mono and gtk-sharp should do the trick.

17 |

Usage:

18 |

Just start the SoundCenSeGTK.exe (linux users without binutils fix need to use 'mono SoundCenSe.exe').

19 |

First start:

20 |

Since no sound files are provided in this download, you need to update the sound packs first or point the Soundpack Path to the appropriate folder. 21 | More on that below

22 |

The audio tab

23 |

On the audio tab you see the different channels (SFX, music, weather, swords and trading). 24 | On the right side of each of the channels you have a volume and a mute control. Changes are save on closing SoundCenSe.

25 |

On the bottom of each channel you can show/hide the last 5 played sounds, which you can disable with the little button on the left side. Once you disabled a sound, it will not be played anymore until you remove it again from the Disabled Sounds tab, by again clicking the little button on the left side.

26 |

The update tab

27 |

By clicking Update Soundpack the chosen soundpack folder will be checked and updated accordingly. 28 | Please wait for the update to finish until you start Dwarf Fortress.

29 |

The configuration tab

30 |

First, there is the path to the soundpack folder. Click on the ... button to change it.

31 |

Windows users have an additional checkbox for auto-detection of dwarf fortress or static path to the gamelog. 32 | If you choose to use a static path, you can click the ... button to change the folder.

33 |

The credits tab

34 |

Especially pay attention to this tab, since without these guys, there wouldn't be a SoundCenSe at all.

35 |

Credits:

36 | 42 |

Last changed: 9/7/2017 10:20:32 AM

43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SoundCenSe v1.4.4 # 2 | 3 | SoundCenSe is a audio engine for Dwarf Fortress based on ZweiStein's SoundSense written in c#/gtk. 4 | 5 | **System requirements:** 6 | 7 | Windows: 8 | 9 | - .NET 4.0 ([https://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe](https://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe)) 10 | - GTK-Sharp ([http://download.xamarin.com/GTKforWindows/Windows/gtk-sharp-2.12.38.msi](http://download.xamarin.com/GTKforWindows/Windows/gtk-sharp-2.12.38.msi)) 11 | - Microsoft Visual c++ runtime redistributables 2013 ([https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x86.exe](https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x86.exe)) 12 | 13 | If it doesn't seem to start, please check the Log.txt, there might be clues to what is missing. 14 | 15 | 16 | Linux: 17 | 18 | - mono-complete 19 | - gtk-sharp2 20 | 21 | Don't know for sure for OSX, but mono and gtk-sharp should do the trick. 22 | 23 | 24 | **Usage:** 25 | 26 | Just start the SoundCenSeGTK.exe (linux users without binutils fix need to use 'mono SoundCenSe.exe'). 27 | 28 | ## First start: ## 29 | 30 | Since no sound files are provided in this download, you need to update the sound packs first or point the Soundpack Path to the appropriate folder. 31 | More on that below 32 | 33 | ## The audio tab ## 34 | On the audio tab you see the different channels (SFX, music, weather, swords and trading). 35 | On the right side of each of the channels you have a volume and a mute control. Changes are save on closing SoundCenSe. 36 | 37 | On the bottom of each channel you can show/hide the last 5 played sounds, which you can disable with the little button on the left side. Once you disabled a sound, it will not be played anymore until you remove it again from the *Disabled Sounds* tab, by again clicking the little button on the left side. 38 | 39 | ## The update tab ## 40 | By clicking *Update Soundpack* the chosen soundpack folder will be checked and updated accordingly. 41 | Please wait for the update to finish until you start Dwarf Fortress. 42 | 43 | ## The configuration tab ## 44 | First, there is the path to the soundpack folder. Click on the ... button to change it. 45 | 46 | Windows users have an additional checkbox for auto-detection of dwarf fortress or static path to the gamelog. 47 | If you choose to use a static path, you can click the ... button to change the folder. 48 | 49 | ## The credits tab ## 50 | Especially pay attention to this tab, since without these guys, there wouldn't be a SoundCenSe at all. 51 | 52 | 53 | 54 | Credits: 55 | 56 | - Toady One and ThreeToe for Dwarf Fortress 57 | - Firelight Techonologies for fmod audio libraries 58 | - ZweiStein for his good work on SoundSense 59 | - jecowa for his efforts on OSX testing 60 | 61 | 62 | Last changed: 9/7/2017 10:20:32 AM 63 | -------------------------------------------------------------------------------- /SoundCenSe GTK/ArrowDown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe GTK/ArrowDown.png -------------------------------------------------------------------------------- /SoundCenSe GTK/ArrowUp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe GTK/ArrowUp.png -------------------------------------------------------------------------------- /SoundCenSe GTK/DisableSound 15x15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe GTK/DisableSound 15x15.png -------------------------------------------------------------------------------- /SoundCenSe GTK/FastForward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe GTK/FastForward.png -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Enums/Loop.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public enum Loop 6 | { 7 | Start_Looping, 8 | Stop_Looping 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Enums/RunState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public enum RunState 6 | { 7 | Startup=0, 8 | Updating, 9 | LookingForDF, 10 | PlayingDF 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Enums/Threshold.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public enum Threshold : long 6 | { 7 | Everything = 4, 8 | Fluffy = 3, 9 | Important = 2, 10 | Critical = 1, 11 | Nothing = 0 12 | } 13 | 14 | } 15 | 16 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Events/ChannelFastForwardEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public class ChannelFastForwardEventArgs : EventArgs 6 | {public string ChannelName {get;set;} 7 | 8 | public ChannelFastForwardEventArgs (string channelName) 9 | { 10 | ChannelName = channelName; 11 | } 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Events/ChannelMuteEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public class ChannelMuteEventArgs : EventArgs 6 | { 7 | public string Channel { get; set; } 8 | 9 | public bool Mute { get; set; } 10 | 11 | public ChannelMuteEventArgs (string channel, bool mute) 12 | { 13 | Channel = channel; 14 | Mute = mute; 15 | } 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Events/DisableSoundEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public class DisableSoundEventArgs : EventArgs 6 | { 7 | public string Filename {get;set;} 8 | public DisableSoundEventArgs (string filename) 9 | { 10 | this.Filename = filename; 11 | } 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Events/DownloadFinishedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public class DownloadFinishedEventArgs : EventArgs 6 | { 7 | public IDownloadEntry File { get; set; } 8 | 9 | public DownloadFinishedEventArgs(IDownloadEntry file) 10 | { 11 | File = file; 12 | } 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Events/DwarfFortressRunningEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public class DwarfFortressRunningEventArgs : EventArgs 6 | { 7 | #region Properties 8 | 9 | public int ProcessId { get; set; } 10 | 11 | #endregion 12 | 13 | public DwarfFortressRunningEventArgs (int processId) 14 | { 15 | ProcessId = processId; 16 | } 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Events/DwarfFortressStoppedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public class DwarfFortressStoppedEventArgs : EventArgs 6 | { 7 | public DwarfFortressStoppedEventArgs () 8 | { 9 | } 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Events/GamelogEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public class GamelogEventArgs : EventArgs 6 | { 7 | #region Properties 8 | 9 | public string Line { get; set; } 10 | 11 | #endregion 12 | 13 | public GamelogEventArgs(string line) 14 | { 15 | Line = line; 16 | } 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Events/RestartSoundLoopEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public class RestartSoundLoopEventArgs : EventArgs 6 | { 7 | #region Properties 8 | 9 | public ISoundSoundFile SoundSoundFile { get; set; } 10 | 11 | #endregion 12 | 13 | public RestartSoundLoopEventArgs(ISoundSoundFile soundSoundFile) 14 | { 15 | SoundSoundFile = soundSoundFile; 16 | } 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Events/SoundFinishedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public class SoundFinishedEventArgs : EventArgs 6 | { 7 | #region Properties 8 | 9 | public ISound Sound { get; set; } 10 | public ISoundFile SoundFile { get; set; } 11 | 12 | #endregion 13 | 14 | public SoundFinishedEventArgs(ISound sound, ISoundFile soundFile) 15 | { 16 | Sound = sound; 17 | SoundFile = soundFile; 18 | } 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Events/SoundPlayingEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public class SoundPlayingEventArgs : EventArgs 6 | { 7 | #region Properties 8 | 9 | public bool Mute { get; set; } 10 | 11 | public ISound Sound { get; set; } 12 | public ISoundFile SoundFile { get; set; } 13 | public float Volume { get; set; } 14 | 15 | #endregion 16 | 17 | public SoundPlayingEventArgs(ISound sound, ISoundFile soundFile, bool mute, float volume) 18 | { 19 | Sound = sound; 20 | SoundFile = soundFile; 21 | Mute = mute; 22 | Volume = volume; 23 | } 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Events/StartDownloadEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | 6 | public class StartDownloadEventArgs : EventArgs 7 | { 8 | #region Properties 9 | 10 | public IDownloadEntry File { get; set; } 11 | 12 | #endregion 13 | 14 | public StartDownloadEventArgs(IDownloadEntry file) 15 | { 16 | File = file; 17 | } 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Events/UpdateFinishedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public class UpdateFinishedEventArgs:EventArgs 6 | { 7 | public bool ReloadNeeded { get; set; } 8 | 9 | public UpdateFinishedEventArgs(bool reload) 10 | { 11 | ReloadNeeded = reload; 12 | } 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Events/VolumeChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public class VolumeChangedEventArgs : EventArgs 6 | { 7 | public string Channel { get; set; } 8 | 9 | public double Volume { get; set; } 10 | 11 | public VolumeChangedEventArgs (string channel, double volume) 12 | { 13 | Channel = channel; 14 | Volume = volume; 15 | } 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Events/XMLParseDoneEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public class XMLParseDoneEventArgs : EventArgs 6 | { 7 | public XMLParseDoneEventArgs () 8 | { 9 | } 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Events/XMLParseProgressEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public class XMLParseProgressEventArgs : EventArgs 6 | { 7 | #region Properties 8 | 9 | public string Filename { get; set; } 10 | 11 | #endregion 12 | 13 | public XMLParseProgressEventArgs(string filename) 14 | { 15 | Filename = filename; 16 | } 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Interfaces/DownloadResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public enum DownloadResult 6 | { 7 | OK, 8 | Error404, 9 | ErrorSHA, 10 | ErrorSize 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Interfaces/IDownloadEntry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | 4 | namespace Misc 5 | { 6 | public interface IDownloadEntry 7 | { 8 | string DestinationPath { get; set; } 9 | 10 | string ExpectedSHA { get; set; } 11 | 12 | long ExpectedSize { get; set; } 13 | 14 | DownloadResult Result { get; set; } 15 | 16 | string SourceURL { get; set; } 17 | 18 | HttpStatusCode StatusCode { get; set; } 19 | 20 | string TempFileName { get; set; } 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Interfaces/IPlayerManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public interface IPlayerManager 6 | { 7 | #region Properties 8 | 9 | Threshold Threshold { get; set; } 10 | float Volume { get; set; } 11 | 12 | #endregion 13 | 14 | void Play(ISound sound, long x, long y, long z); 15 | 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Interfaces/IPlaylistParser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | 5 | namespace Misc 6 | { 7 | public interface IPlaylistParser 8 | { 9 | /// 10 | /// Parse the playlist file 11 | /// 12 | /// Name of the parent XML file 13 | /// Input stream of the playlist file 14 | /// List of audio file names 15 | List Parse(string parentFilename, Stream input); 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Interfaces/ISound.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.RegularExpressions; 3 | 4 | namespace Misc 5 | { 6 | public interface ISound 7 | { 8 | string AnsiFormat { get; set; } 9 | 10 | string Channel { get; set; } 11 | 12 | long Concurrency { get; set; } 13 | 14 | long Delay { get; set; } 15 | 16 | bool HaltOnMatch { get; set; } 17 | 18 | long Hits { get; set; } 19 | 20 | long LastPlayed { get; set; } 21 | 22 | string logPattern { get; set; } 23 | 24 | Loop loop { get; set; } 25 | 26 | string ParentFile { get; set; } 27 | 28 | Regex parsedPattern { get; set; } 29 | 30 | long PlaybackThreshold { get; set; } 31 | 32 | long Probability { get; set; } 33 | 34 | int SoundFilesWeightSum { get; set; } 35 | 36 | long Timeout { get; set; } 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Interfaces/ISoundFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public interface ISoundFile 6 | { 7 | float BalanceAdjustment { get; set; } 8 | 9 | bool Disabled { get; set; } 10 | 11 | string Filename { get; set; } 12 | 13 | uint Length { get; set; } 14 | bool RandomBalance { get; set; } 15 | float VolumeAdjustment { get; set; } 16 | 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Interfaces/ISoundSoundFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public interface ISoundSoundFile 6 | { 7 | ISound Sound { get; set; } 8 | ISoundFile SoundFile { get; set; } 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Misc.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | {9805FF66-0D87-4C93-AF45-A92873446903} 7 | Library 8 | Misc 9 | Misc 10 | 1.4.2 11 | 12 | 13 | true 14 | full 15 | false 16 | bin\Debug 17 | DEBUG; 18 | prompt 19 | 4 20 | false 21 | x86 22 | 23 | 24 | true 25 | bin\Release 26 | prompt 27 | 4 28 | false 29 | x86 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 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle ("Misc")] 8 | [assembly: AssemblyDescription ("")] 9 | [assembly: AssemblyConfiguration ("")] 10 | [assembly: AssemblyCompany ("")] 11 | [assembly: AssemblyProduct ("")] 12 | [assembly: AssemblyCopyright ("chris")] 13 | [assembly: AssemblyTrademark ("")] 14 | [assembly: AssemblyCulture ("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion ("1.0.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | 28 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Misc/StringExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Misc 4 | { 5 | public static class StringExtension 6 | { 7 | 8 | public static string Capitalize(this string s) 9 | { 10 | // Check for empty string. 11 | if (string.IsNullOrEmpty(s)) 12 | { 13 | return string.Empty; 14 | } 15 | // Return char and concat substring. 16 | return char.ToUpper(s[0]) + s.Substring(1); 17 | } 18 | 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /SoundCenSe GTK/Mute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe GTK/Mute.png -------------------------------------------------------------------------------- /SoundCenSe GTK/Program.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe GTK/Program.ico -------------------------------------------------------------------------------- /SoundCenSe GTK/SignalGreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe GTK/SignalGreen.png -------------------------------------------------------------------------------- /SoundCenSe GTK/SignalRed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe GTK/SignalRed.png -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Config.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NLog; 3 | using Newtonsoft; 4 | 5 | namespace SoundCenSeGTK 6 | { 7 | public class Config 8 | { 9 | #region Fields and Constants 10 | 11 | public static ConfigurationData Instance; 12 | private static Logger logger = LogManager.GetCurrentClassLogger(); 13 | 14 | #endregion 15 | 16 | public Config(string filename) 17 | { 18 | Load(filename); 19 | } 20 | 21 | public static void Load(string filename) 22 | { 23 | Instance = ConfigurationData.Load(filename); 24 | } 25 | 26 | public static void Save(string filename) 27 | { 28 | Instance.Save(filename); 29 | } 30 | } 31 | } 32 | 33 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "achievements": false, 3 | "allowPackOverride": true, 4 | "autoUpdateURLs": [ 5 | "http://df.zweistein.cz/soundsense/soundpack", 6 | "http://www.armedassault.info/_hosted/soundsense/au" 7 | ], 8 | "Channels": [ 9 | { 10 | "Channel": "weather", 11 | "Mute": false, 12 | "Volume": 1.0 13 | }, 14 | { 15 | "Channel": "music", 16 | "Mute": false, 17 | "Volume": 1.0 18 | }, 19 | { 20 | "Channel": "swords", 21 | "Mute": false, 22 | "Volume": 1.0 23 | }, 24 | { 25 | "Channel": "trade", 26 | "Mute": false, 27 | "Volume": 1.0 28 | }, 29 | { 30 | "Channel": "sfx", 31 | "Mute": false, 32 | "Volume": 1.0 33 | } 34 | ], 35 | "deleteFiles": true, 36 | "disabledSounds": [], 37 | "expectedMinimalSoundsCound": 0, 38 | "gamelogEncoding": "Cp850", 39 | "gamelogPath": "../df_linux/gamelog.txt", 40 | "gui": true, 41 | "mutedChannels": [], 42 | "noWarnAbsolutePaths": false, 43 | "playbackThreshold": 4, 44 | "replaceFiles": true, 45 | "soundpacksPath": "./packs/", 46 | "supplementalLogs": [], 47 | "volume": 0.0, 48 | "autoDetect": true 49 | } 50 | 51 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Configuration/ChannelData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SoundCenSeGTK 4 | { 5 | public class ChannelData 6 | { 7 | #region Properties 8 | 9 | public string Channel { get; set; } 10 | public bool Mute { get; set; } 11 | public float Volume { get; set; } 12 | 13 | #endregion 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Configuration/ConfigurationData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using System.Collections.Generic; 5 | using Newtonsoft.Json; 6 | using Misc; 7 | 8 | namespace SoundCenSeGTK 9 | { 10 | public class ConfigurationData 11 | { 12 | #region Properties 13 | 14 | public bool achievements { get; set; } 15 | 16 | public bool allowPackOverride { get; set; } 17 | 18 | public List autoUpdateURLs { get; set; } 19 | 20 | public List Channels { get; set; } 21 | 22 | public bool deleteFiles { get; set; } 23 | 24 | public HashSet disabledSounds { get; set; } 25 | 26 | public long expectedMinimalSoundsCound { get; set; } 27 | 28 | public string fileName { get; set; } 29 | 30 | public string gamelogEncoding { get; set; } 31 | 32 | public string gamelogPath { get; set; } 33 | 34 | public bool gui { get; set; } 35 | 36 | public HashSet mutedChannels { get; set; } 37 | 38 | public bool noWarnAbsolutePaths { get; set; } 39 | 40 | public Threshold playbackThreshold { get; set; } 41 | 42 | public bool replaceFiles { get; set; } 43 | 44 | public string soundpacksPath { get; set; } 45 | 46 | public List supplementalLogs { get; set; } 47 | 48 | public float volume { get; set; } 49 | 50 | public bool autoDetect { get; set; } 51 | 52 | #endregion 53 | 54 | public ConfigurationData() 55 | { 56 | autoUpdateURLs = new List(); 57 | disabledSounds = new HashSet(); 58 | mutedChannels = new HashSet(); 59 | supplementalLogs = new List(); 60 | Channels = new List(); 61 | } 62 | 63 | public ChannelData GetChannelData(string channel) 64 | { 65 | ChannelData cx = Channels.FirstOrDefault(x => x.Channel == channel); 66 | if (cx == null) 67 | { 68 | // Dummy if not in list 69 | cx = new ChannelData(); 70 | cx.Volume = 1.0f; 71 | cx.Mute = false; 72 | cx.Channel = ""; 73 | } 74 | return cx; 75 | } 76 | 77 | public static ConfigurationData Load(string filename) 78 | { 79 | using (TextReader tr = new StreamReader(filename)) 80 | { 81 | return JsonConvert.DeserializeObject(tr.ReadToEnd()); 82 | } 83 | } 84 | 85 | public void MuteChannel(string channel, bool mute) 86 | { 87 | foreach (ChannelData cd in Channels) 88 | { 89 | if (cd.Channel == channel) 90 | { 91 | cd.Mute = mute; 92 | return; 93 | } 94 | } 95 | ChannelData cdNew = new ChannelData(); 96 | cdNew.Channel = channel; 97 | cdNew.Mute = mute; 98 | cdNew.Volume = 1.0f; 99 | Channels.Add(cdNew); 100 | } 101 | 102 | public void Save(string filename) 103 | { 104 | using (TextWriter tw = new StreamWriter(filename)) 105 | { 106 | tw.WriteLine(JsonConvert.SerializeObject(this, Formatting.Indented)); 107 | } 108 | } 109 | 110 | public void SetChannelVolume(string channel, float vol) 111 | { 112 | foreach (ChannelData cd in Channels) 113 | { 114 | if (cd.Channel == channel) 115 | { 116 | cd.Volume = vol; 117 | return; 118 | } 119 | } 120 | ChannelData cdNew = new ChannelData(); 121 | cdNew.Channel = channel; 122 | cdNew.Mute = false; 123 | cdNew.Volume = vol; 124 | Channels.Add(cdNew); 125 | } 126 | } 127 | } 128 | 129 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Configuration/Sounds/Attribution.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NLog; 3 | using System.Xml; 4 | 5 | namespace SoundCenSeGTK 6 | { 7 | public class Attribution 8 | { 9 | #region Fields and Constants 10 | 11 | private static readonly Logger logger = LogManager.GetCurrentClassLogger(); 12 | 13 | #endregion 14 | 15 | #region Properties 16 | 17 | public string Author { get; set; } 18 | public string Description { get; set; } 19 | public string License { get; set; } 20 | public string Note { get; set; } 21 | 22 | public string Url { get; set; } 23 | 24 | #endregion 25 | 26 | public Attribution(string url, string license, string author, string description, string note) 27 | { 28 | Url = url; 29 | License = license; 30 | Author = author; 31 | Description = description; 32 | Note = note; 33 | } 34 | 35 | public static Attribution ReadFromXML(XmlNode node, SoundFile soundfile) 36 | { 37 | string url = node.ParseStringAttribute("url", null); 38 | string license = node.ParseStringAttribute("license", null); 39 | string author = node.ParseStringAttribute("author", null); 40 | string description = node.ParseStringAttribute("description", null); 41 | string note = node.ParseStringAttribute("note", ""); 42 | 43 | if (string.IsNullOrEmpty(url)) 44 | { 45 | logger.Info("Attribution url is not set for " + soundfile.Filename); 46 | return null; 47 | } 48 | if (string.IsNullOrEmpty(license)) 49 | { 50 | logger.Info("Attribution license is not set for " + soundfile.Filename); 51 | return null; 52 | } 53 | if (string.IsNullOrEmpty(author)) 54 | { 55 | logger.Info("Attribution author is not set for " + soundfile.Filename); 56 | return null; 57 | } 58 | return new Attribution(url, license, author, description, note); 59 | } 60 | 61 | public override string ToString() 62 | { 63 | return Url; 64 | } 65 | } 66 | } 67 | 68 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Configuration/Sounds/Playlist.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SoundCenSeGTK 4 | { 5 | public class Playlist 6 | { 7 | public Playlist () 8 | { 9 | } 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Configuration/Sounds/Playlist/M3UParser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using NLog; 5 | using Misc; 6 | 7 | namespace SoundCenSeGTK 8 | { 9 | public class M3UParser : IPlaylistParser 10 | { 11 | #region Fields and Constants 12 | 13 | private static readonly Logger logger = LogManager.GetCurrentClassLogger (); 14 | 15 | #endregion 16 | 17 | #region IPlaylistParser Members 18 | 19 | /// 20 | /// Parse M3U file stream 21 | /// 22 | /// Name of the parent XML file 23 | /// Input stream of the playlist 24 | /// List of audio file names 25 | public List Parse (string parentFilename, Stream input) 26 | { 27 | List playlist = new List (); 28 | 29 | TextReader tr = new StreamReader (input); 30 | string line = tr.ReadLine (); 31 | 32 | if (line == "#EXTM3U") 33 | { 34 | while (line != null) 35 | { 36 | if (!line.StartsWith ("#") && !string.IsNullOrEmpty (line)) 37 | { 38 | string soundFilename = Path.Combine (Path.GetDirectoryName (parentFilename), line); 39 | if (!File.Exists (soundFilename)) 40 | { 41 | if (File.Exists (line)) 42 | { 43 | soundFilename = line; 44 | } 45 | else 46 | { 47 | logger.Warn ("Did not find " + soundFilename + ", ignoring."); 48 | soundFilename = null; 49 | } 50 | } 51 | if (!string.IsNullOrEmpty (soundFilename)) 52 | { 53 | playlist.Add (soundFilename); 54 | } 55 | } 56 | line = tr.ReadLine (); 57 | } 58 | } 59 | else 60 | { 61 | throw new Exception ("Wrong header for playlist"); 62 | } 63 | 64 | return playlist; 65 | } 66 | 67 | #endregion 68 | } 69 | } 70 | 71 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Configuration/Sounds/Playlist/PLSParser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using NLog; 5 | using Misc; 6 | 7 | namespace SoundCenSeGTK 8 | { 9 | /// 10 | /// Parser for PLS playlists 11 | /// 12 | public class PLSParser : IPlaylistParser 13 | { 14 | #region Fields and Constants 15 | 16 | private static readonly Logger logger = LogManager.GetCurrentClassLogger(); 17 | 18 | #endregion 19 | 20 | #region IPlaylistParser Members 21 | 22 | /// 23 | /// Parse PLS file stream 24 | /// 25 | /// Name of the parent XML file 26 | /// Input stream of the playlist 27 | /// List of audio file names 28 | public List Parse(string parentFilename, Stream input) 29 | { 30 | List playlist = new List(); 31 | TextReader tr = new StreamReader(input); 32 | 33 | string line = tr.ReadLine(); 34 | 35 | if (line == "[playlist]") 36 | { 37 | while (line != null) 38 | { 39 | if (line.StartsWith("File")) 40 | { 41 | string[] fileparts = line.Split('='); 42 | string soundFilename = Path.Combine(Path.GetDirectoryName(parentFilename), fileparts[1]); 43 | if (!File.Exists(soundFilename)) 44 | { 45 | if (File.Exists(fileparts[1])) 46 | { 47 | soundFilename = fileparts[1]; 48 | } 49 | else 50 | { 51 | logger.Warn("Did not find " + soundFilename + ", ignoring."); 52 | soundFilename = null; 53 | } 54 | } 55 | if (!string.IsNullOrEmpty(soundFilename)) 56 | { 57 | playlist.Add(soundFilename); 58 | } 59 | } 60 | line = tr.ReadLine(); 61 | } 62 | } 63 | else 64 | { 65 | throw new Exception("Wrong header for playlist"); 66 | } 67 | return playlist; 68 | } 69 | 70 | #endregion 71 | } 72 | } 73 | 74 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Configuration/Sounds/Sound.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Collections.Generic; 4 | using System.Text.RegularExpressions; 5 | using Misc; 6 | 7 | namespace SoundCenSeGTK 8 | { 9 | public class Sound : ISound, IDisposable 10 | { 11 | #region Fields and Constants 12 | 13 | public List SoundFiles = new List(); 14 | 15 | #endregion 16 | 17 | #region Properties 18 | 19 | public string AnsiFormat { get; set; } 20 | public string Channel { get; set; } 21 | public long Concurrency { get; set; } 22 | public long Delay { get; set; } 23 | public bool HaltOnMatch { get; set; } 24 | public long Hits { get; set; } 25 | public long LastPlayed { get; set; } 26 | public string logPattern { get; set; } 27 | public Loop loop { get; set; } 28 | public string ParentFile { get; set; } 29 | public Regex parsedPattern { get; set; } 30 | public long PlaybackThreshold { get; set; } 31 | public long Probability { get; set; } 32 | 33 | public int SoundFilesWeightSum { get; set; } 34 | public long Timeout { get; set; } 35 | 36 | #endregion 37 | 38 | public Sound(string parentFile, List soundfiles, string pattern, string ansiFormat, Loop _loop, 39 | string channel, long concurrency, bool haltOnMatch, long timeout, long delay, long probability, 40 | long playbackThreshold) 41 | { 42 | ParentFile = parentFile; 43 | if (soundfiles != null) 44 | { 45 | SoundFiles.AddRange(soundfiles.OrderByDescending(x => x.Weight).ToArray()); 46 | } 47 | logPattern = pattern; 48 | loop = _loop; 49 | Channel = channel; 50 | Concurrency = concurrency; 51 | HaltOnMatch = haltOnMatch; 52 | Hits = 0; 53 | Probability = probability; 54 | PlaybackThreshold = playbackThreshold; 55 | AnsiFormat = ansiFormat; 56 | SoundFilesWeightSum = 0; 57 | Delay = delay; 58 | Timeout = timeout; 59 | foreach (SoundFile sf in SoundFiles) 60 | { 61 | SoundFilesWeightSum += sf.Weight; 62 | } 63 | 64 | if (!string.IsNullOrEmpty(logPattern)) 65 | { 66 | parsedPattern = new Regex(logPattern); 67 | } 68 | } 69 | 70 | #region IDisposable Members 71 | 72 | public void Dispose() 73 | { 74 | Dispose(true); 75 | GC.SuppressFinalize(this); 76 | } 77 | 78 | #endregion 79 | 80 | private void Dispose(bool disposing) 81 | { 82 | if (disposing) 83 | { 84 | foreach (SoundFile sf in SoundFiles) 85 | { 86 | sf.Dispose(); 87 | } 88 | } 89 | } 90 | private Random rnd = new Random(); 91 | 92 | public SoundFile GetRandomSoundFile() 93 | { 94 | int disabled = SoundFiles.Count(x => x.Disabled); 95 | if ((SoundFiles.Count > 0) && (disabled < SoundFiles.Count)) 96 | { 97 | int weightSum = SoundFilesWeightSum; 98 | if (disabled > 0) 99 | { 100 | foreach (SoundFile sf in SoundFiles.Where(x => x.Disabled)) 101 | { 102 | weightSum -= sf.Weight; 103 | } 104 | } 105 | 106 | int weightedrandom = rnd.Next(weightSum); 107 | foreach (SoundFile sf in SoundFiles.Where(x => !x.Disabled)) 108 | { 109 | if (sf.Weight > weightedrandom) 110 | { 111 | return sf; 112 | } 113 | weightedrandom -= sf.Weight; 114 | } 115 | } 116 | return null; 117 | } 118 | 119 | public bool HasNoSoundFiles() 120 | { 121 | return SoundFiles.Count == 0; 122 | } 123 | 124 | public void Hit() 125 | { 126 | Hits++; 127 | } 128 | 129 | public bool Matches(string line) 130 | { 131 | return parsedPattern.IsMatch(line); 132 | } 133 | 134 | public override string ToString() 135 | { 136 | return ParentFile; 137 | } 138 | } 139 | } 140 | 141 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Configuration/Sounds/SoundFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Misc; 4 | 5 | namespace SoundCenSeGTK 6 | { 7 | public class SoundFile : ISoundFile, IDisposable 8 | { 9 | #region Fields and Constants 10 | 11 | public List Attributions = new List(); 12 | public int Weight = 100; 13 | 14 | #endregion 15 | 16 | #region Properties 17 | 18 | public float BalanceAdjustment { get; set; } 19 | 20 | public bool Disabled { get; set; } 21 | 22 | public string Filename { get; set; } 23 | 24 | public uint Length { get; set; } 25 | public bool RandomBalance { get; set; } 26 | public float VolumeAdjustment { get; set; } 27 | 28 | #endregion 29 | 30 | public SoundFile(string filename, int weight, float volumeAdjustment, float balanceAdjustment, 31 | bool randomBalance) 32 | { 33 | Filename = filename; 34 | Weight = weight; 35 | VolumeAdjustment = volumeAdjustment; 36 | BalanceAdjustment = balanceAdjustment; 37 | RandomBalance = randomBalance; 38 | } 39 | 40 | #region IDisposable Members 41 | 42 | public void Dispose() 43 | { 44 | Dispose(true); 45 | GC.SuppressFinalize(this); 46 | } 47 | 48 | #endregion 49 | 50 | private void Dispose(bool disposing) 51 | { 52 | if (disposing) 53 | { 54 | } 55 | } 56 | 57 | public override string ToString() 58 | { 59 | return Filename; 60 | } 61 | } 62 | } 63 | 64 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Configuration/XMLExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | using System.Collections.Generic; 4 | using NLog; 5 | 6 | namespace SoundCenSeGTK 7 | { 8 | public static class XmlExtensions 9 | { 10 | #region Fields and Constants 11 | 12 | private static readonly Logger logger = LogManager.GetCurrentClassLogger(); 13 | 14 | #endregion 15 | 16 | public static bool ParseBoolAttribute(this XmlNode node, string attributeName, bool defaultValue) 17 | { 18 | bool result = defaultValue; 19 | XmlNode boolNode = node.Attributes.GetNamedItem(attributeName); 20 | if (boolNode != null) 21 | { 22 | if (boolNode.Value.Equals("true")) 23 | { 24 | result = true; 25 | } 26 | else if (boolNode.Value.Equals("false")) 27 | { 28 | result = false; 29 | } 30 | else 31 | { 32 | logger.Warn("XML Warning: " + attributeName + "'s value is not recognized, using default value " + 33 | defaultValue); 34 | } 35 | } 36 | return result; 37 | } 38 | 39 | public static bool ParseBooleanTag(this XmlElement element, string nodeName) 40 | { 41 | XmlNode node = element.GetElementsByTagName(nodeName).Item(0); 42 | return node.ParseBoolAttribute("value", true); 43 | } 44 | 45 | public static float ParseFloatAttribute(this XmlNode node, string attributeName, float defaultValue) 46 | { 47 | float result = defaultValue; 48 | XmlNode floatNode = node.Attributes.GetNamedItem(attributeName); 49 | if (floatNode != null) 50 | { 51 | string text = floatNode.Value; 52 | if (!float.TryParse(text, out result)) 53 | { 54 | logger.Warn("XML Warning: " + attributeName + "'s value is not recognized, using default value " + 55 | defaultValue); 56 | } 57 | } 58 | return result; 59 | } 60 | 61 | public static int ParseIntAttribute(this XmlNode node, string attributeName, int defaultValue) 62 | { 63 | int result = defaultValue; 64 | XmlNode intNode = node.Attributes.GetNamedItem(attributeName); 65 | if (intNode != null) 66 | { 67 | string text = intNode.Value; 68 | if (!int.TryParse(text, out result)) 69 | { 70 | logger.Warn("XML Warning: " + attributeName + "'s value is not recognized, using default value " + 71 | defaultValue); 72 | } 73 | } 74 | return result; 75 | } 76 | 77 | public static long ParseLongAttribute(this XmlNode node, string attributeName, long defaultValue) 78 | { 79 | long result = defaultValue; 80 | XmlNode longNode = node.Attributes.GetNamedItem(attributeName); 81 | if (longNode != null) 82 | { 83 | string text = longNode.Value; 84 | if (!long.TryParse(text, out result)) 85 | { 86 | logger.Warn("XML Warning: " + attributeName + "'s value is not recognized, using default value " + 87 | defaultValue); 88 | } 89 | } 90 | return result; 91 | } 92 | 93 | public static List ParsePathList(this XmlNode node) 94 | { 95 | List list = new List(); 96 | 97 | XmlNodeList items = node.ChildNodes; 98 | foreach (XmlNode n in items) 99 | { 100 | string name = n.LocalName; 101 | if (name == "item") 102 | { 103 | list.Add(n.Attributes.GetNamedItem("path").Value); 104 | } 105 | } 106 | return list; 107 | } 108 | 109 | public static string ParseStringAttribute(this XmlNode node, string attributeName, string defaultValue) 110 | { 111 | string result = defaultValue; 112 | XmlNode stringNode = node.Attributes.GetNamedItem(attributeName); 113 | if (stringNode != null) 114 | { 115 | result = stringNode.Value; 116 | } 117 | return result; 118 | } 119 | } 120 | } 121 | 122 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/FmodSystem.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: FmodSystem.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | using System.Collections.Generic; 12 | using FMOD; 13 | using NLog; 14 | using System.Diagnostics; 15 | 16 | namespace SoundCenSeGTK 17 | { 18 | public static class FmodSystem 19 | { 20 | #region Fields and Constants 21 | 22 | private static Logger logger = LogManager.GetCurrentClassLogger(); 23 | 24 | private static FMOD.System _system; 25 | 26 | public static Dictionary RawChannels = new Dictionary(); 27 | 28 | #endregion 29 | 30 | #region Properties 31 | 32 | public static FMOD.System System 33 | { 34 | get 35 | { 36 | if (_system == null) 37 | { 38 | Factory.System_Create(out _system); 39 | RESULT r = _system.init(32, INITFLAGS.NORMAL, IntPtr.Zero); 40 | if (r != RESULT.OK) 41 | { 42 | MessageBox.Show("Failed to initialize FMOD sound system: " + r); 43 | return null; 44 | } 45 | } 46 | return _system; 47 | } 48 | } 49 | 50 | #endregion 51 | 52 | public static void AddC(Channel c) 53 | { 54 | int id; 55 | c.getIndex(out id); 56 | if (RawChannels.ContainsKey(id)) 57 | { 58 | RawChannels[id] = c; 59 | } 60 | else 61 | { 62 | RawChannels.Add(id, c); 63 | } 64 | } 65 | 66 | public static void ERRCHECK(RESULT result) 67 | { 68 | if (result != RESULT.OK) 69 | { 70 | logger.Info("FMOD Error: " + result.ToString()); 71 | logger.Info(new StackTrace().ToString()); 72 | } 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Input/LogFileListener.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NLog; 3 | using Misc; 4 | using System.IO; 5 | using System.Text.RegularExpressions; 6 | 7 | namespace SoundCenSeGTK 8 | { 9 | public sealed class LogFileListener : IDisposable 10 | { 11 | #region Fields and Constants 12 | 13 | public static readonly Logger logger = LogManager.GetCurrentClassLogger(); 14 | public EventHandler GamelogEvent; 15 | private TextReader logfileReader; 16 | private FileStream logFileStream; 17 | 18 | #endregion 19 | 20 | public LogFileListener(string filename, bool beginAtEnd = false) 21 | { 22 | logFileStream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); 23 | logfileReader = new StreamReader(logFileStream); 24 | if (beginAtEnd) 25 | { 26 | BeginAtEnd(); 27 | } 28 | } 29 | 30 | #region IDisposable Members 31 | 32 | public void Dispose() 33 | { 34 | Dispose(true); 35 | GC.SuppressFinalize(this); 36 | } 37 | 38 | #endregion 39 | 40 | #region IStoppable Members 41 | 42 | public void Start() 43 | { 44 | } 45 | 46 | public void Stop() 47 | { 48 | } 49 | 50 | #endregion 51 | 52 | public void BeginAtEnd() 53 | { 54 | logfileReader.ReadToEnd(); 55 | } 56 | 57 | private void Dispose(bool disposing) 58 | { 59 | if (disposing) 60 | { 61 | Stop(); 62 | logfileReader.Dispose(); 63 | logFileStream.Dispose(); 64 | logfileReader = null; 65 | logFileStream = null; 66 | } 67 | } 68 | 69 | public void Tick() 70 | { 71 | if (logfileReader == null) 72 | { 73 | return; 74 | } 75 | while (true) 76 | { 77 | try 78 | { 79 | string line = logfileReader.ReadLine(); 80 | if (line != null) 81 | { 82 | OnLogfileEvent(line); 83 | } 84 | else 85 | { 86 | break; 87 | } 88 | } 89 | catch (Exception ex) 90 | { 91 | logger.Error("Exception while reading gamelog"); 92 | logger.Error(ex); 93 | } 94 | } 95 | } 96 | 97 | private void OnLogfileEvent(string line) 98 | { 99 | var handler = GamelogEvent; 100 | if (handler != null) 101 | { 102 | handler(this, new GamelogEventArgs(line)); 103 | } 104 | } 105 | } 106 | } 107 | 108 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/MessageBox.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Gtk; 3 | 4 | namespace SoundCenSeGTK 5 | { 6 | public class MessageBox 7 | { 8 | public static void Show(Gtk.Window parent_window, DialogFlags flags, MessageType msgtype, ButtonsType btntype, string msg) 9 | { 10 | MessageDialog md = new MessageDialog (parent_window, flags, msgtype, btntype, msg); 11 | md.Run (); 12 | md.Destroy (); 13 | } 14 | 15 | public static void Show(string msg) 16 | { 17 | MessageDialog md = new MessageDialog (null, DialogFlags.Modal, MessageType.Other, ButtonsType.Ok, msg); 18 | md.Run (); 19 | md.Destroy (); 20 | } 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/NLog.config: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 13 | 14 | 15 | 19 | 20 | 21 | 26 | 27 | 28 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 43 | 44 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Output/DummyPlayerManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Collections.Generic; 4 | using Misc; 5 | 6 | namespace SoundCenSeGTK 7 | { 8 | public class DummyPlayerManager : IPlayerManager 9 | { 10 | #region Fields and Constants 11 | 12 | public readonly Dictionary Channels = new Dictionary(); 13 | 14 | #endregion 15 | 16 | #region IPlayerManager Members 17 | 18 | public Threshold Threshold { get; set; } 19 | 20 | public float Volume { get; set; } 21 | 22 | public void Play(ISound sound, long x, long y, long z) 23 | { 24 | if (sound.PlaybackThreshold <= (long)Config.Instance.playbackThreshold) 25 | { 26 | if (!string.IsNullOrEmpty(sound.Channel)) 27 | { 28 | if (!Channels.ContainsKey(sound.Channel)) 29 | { 30 | Channels.Add(sound.Channel, (Sound)sound); 31 | } 32 | else 33 | { 34 | Channels[sound.Channel] = (Sound)sound; 35 | } 36 | } 37 | } 38 | } 39 | 40 | #endregion 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Output/DummySoundProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Misc; 3 | using System.Linq; 4 | using System.Text.RegularExpressions; 5 | namespace SoundCenSeGTK 6 | { 7 | public class DummySoundProcessor : SoundProcessor 8 | { 9 | #region Properties 10 | 11 | public DummyPlayerManager DummyPlayerManager { get; set; } 12 | 13 | #endregion 14 | 15 | public DummySoundProcessor(SoundsXML sounds) : base(sounds) 16 | { 17 | this.soundsXML.Sounds = sounds.Sounds; 18 | } 19 | 20 | public override void ProcessLine(object sender, GamelogEventArgs e) 21 | { 22 | string line = e.Line; 23 | 24 | int matches = 0; 25 | Sound matchedSound = null; 26 | 27 | if (this.repeater.IsMatch(line)) 28 | { 29 | if (this.lastSFX != null) 30 | { 31 | DummyPlayerManager.Play(this.lastSFX, 0, 0, 0); 32 | } 33 | return; 34 | } 35 | Match matcher = this.coordinatePattern.Match(line); 36 | 37 | long x = long.MinValue; 38 | long y = long.MinValue; 39 | long z = long.MinValue; 40 | if (matcher.Success) 41 | { 42 | x = long.Parse(matcher.Groups[1].Value); 43 | y = long.Parse(matcher.Groups[2].Value); 44 | z = long.Parse(matcher.Groups[3].Value); 45 | line = matcher.Groups[4].Value; 46 | } 47 | 48 | foreach (Sound sound in this.soundsXML.Sounds.Where(sound=>!string.IsNullOrEmpty(sound.Channel))) 49 | { 50 | if (!Config.Instance.disabledSounds.Contains(sound.ParentFile) && 51 | (sound.Matches(line))) 52 | { 53 | matches++; 54 | matchedSound = sound; 55 | 56 | DummyPlayerManager.Play(sound, x, y, z); 57 | 58 | if (string.IsNullOrEmpty(sound.Channel)) 59 | { 60 | this.lastSFX = sound; 61 | } 62 | 63 | if (sound.HaltOnMatch) 64 | { 65 | break; 66 | } 67 | } 68 | } 69 | } 70 | } 71 | } 72 | 73 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Output/SoundProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FMOD; 3 | using NLog; 4 | using System.Text.RegularExpressions; 5 | using Misc; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace SoundCenSeGTK 10 | { 11 | public class SoundProcessor 12 | { 13 | #region Fields and Constants 14 | 15 | private static readonly Logger logger = LogManager.GetCurrentClassLogger(); 16 | private static readonly Logger missingLogger = LogManager.GetLogger("missing"); 17 | internal readonly Regex coordinatePattern; 18 | 19 | internal Sound lastSFX; 20 | 21 | internal readonly Regex repeater = new Regex("^x\\d{1,3}$"); 22 | internal readonly SoundsXML soundsXML; 23 | 24 | #endregion 25 | 26 | public SoundProcessor(SoundsXML sounds) 27 | { 28 | soundsXML = sounds; 29 | coordinatePattern = new Regex("\\[(\\-?\\d),(\\-?\\d),(\\-?\\d)\\] (.*)"); 30 | } 31 | 32 | public virtual void ProcessLine(object sender, GamelogEventArgs e) 33 | { 34 | Task.Factory.StartNew(() => 35 | { 36 | string line = e.Line; 37 | 38 | int matches = 0; 39 | Sound matchedSound = null; 40 | 41 | if (repeater.IsMatch(line)) 42 | { 43 | if (lastSFX != null) 44 | { 45 | fmodPlayer.Instance.Play(lastSFX, 0, 0, 0); 46 | } 47 | return; 48 | } 49 | Match matcher = coordinatePattern.Match(line); 50 | 51 | long x = long.MinValue; 52 | long y = long.MinValue; 53 | long z = long.MinValue; 54 | if (matcher.Success) 55 | { 56 | x = long.Parse(matcher.Groups[1].Value); 57 | y = long.Parse(matcher.Groups[2].Value); 58 | z = long.Parse(matcher.Groups[3].Value); 59 | line = matcher.Groups[4].Value; 60 | } 61 | DateTime dt = DateTime.UtcNow; 62 | int sndChecks = 0; 63 | foreach (Sound sound in soundsXML.Sounds) 64 | { 65 | sndChecks++; 66 | if (!Config.Instance.disabledSounds.Contains(sound.ParentFile) && 67 | (sound.Matches(line))) 68 | { 69 | matches++; 70 | matchedSound = sound; 71 | logger.Info("Message '" + line + "' matched event '" + sound + "' from '" + sound.ParentFile + "'."); 72 | 73 | fmodPlayer.Instance.Play(sound, x, y, z); 74 | 75 | if (string.IsNullOrEmpty(sound.Channel)) 76 | { 77 | lastSFX = sound; 78 | } 79 | 80 | if (sound.HaltOnMatch) 81 | { 82 | logger.Info("Ending Match prematurely as expected."); 83 | break; 84 | } 85 | 86 | logger.Info("Continuing for next rule match."); 87 | } 88 | } 89 | 90 | if (matchedSound == null) 91 | { 92 | logger.Info(line); 93 | logger.Info("Message '" + line + "' did not match any rule."); 94 | missingLogger.Warn(line); 95 | } 96 | else 97 | { 98 | StringBuilder sb = new StringBuilder(); 99 | if (matchedSound.AnsiFormat != null) 100 | { 101 | sb.Append(matchedSound.AnsiFormat); 102 | sb.Append(line); 103 | 104 | logger.Info(sb.ToString()); 105 | logger.Info("Message '" + line + "' matched " + matches + " rules."); 106 | } 107 | } 108 | }); 109 | 110 | } 111 | } 112 | } 113 | 114 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Output/SoundSoundFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Misc; 3 | 4 | namespace SoundCenSeGTK 5 | { 6 | public class SoundSoundFile : ISoundSoundFile 7 | { 8 | #region Properties 9 | 10 | public FMOD.Sound fmodSound { get; set; } 11 | public ISound Sound { get; set; } 12 | public ISoundFile SoundFile { get; set; } 13 | 14 | #endregion 15 | 16 | public SoundSoundFile(Sound sound, SoundFile soundFile) 17 | { 18 | Sound = sound; 19 | SoundFile = soundFile; 20 | } 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Output/fmodChannelPool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Misc; 5 | using NLog; 6 | 7 | namespace SoundCenSeGTK 8 | { 9 | public class FmodChannelPool 10 | { 11 | #region Fields and Constants 12 | 13 | private static FmodChannelPool instance; 14 | public static readonly Logger logger = LogManager.GetCurrentClassLogger(); 15 | 16 | private readonly Dictionary, fmodChannelSound> channels = 17 | new Dictionary, fmodChannelSound>(); 18 | 19 | #endregion 20 | 21 | #region Properties 22 | 23 | public static FmodChannelPool Instance 24 | { 25 | get 26 | { 27 | if (instance == null) 28 | { 29 | instance = new FmodChannelPool(); 30 | } 31 | return instance; 32 | } 33 | } 34 | 35 | #endregion 36 | 37 | public fmodChannelSound GetByRaw(IntPtr raw) 38 | { 39 | return channels.Values.SingleOrDefault(x => x.Channel.getRaw() == raw); 40 | } 41 | 42 | public IEnumerable AllChannels() 43 | { 44 | return channels.Select(x => x.Value); 45 | } 46 | 47 | public int ConcurrentSounds(string channelname) 48 | { 49 | return channels.Count(x => x.Key.Value == channelname); 50 | } 51 | 52 | public fmodChannelSound GetSingleChannel(string channel) 53 | { 54 | if (!channels.Any(x => x.Key.Value == channel.ToLower())) 55 | { 56 | return null; 57 | } 58 | return channels.SingleOrDefault(x => x.Key.Value == channel.ToLower()).Value; 59 | } 60 | 61 | public void RegisterChannel(fmodChannelSound channel) 62 | { 63 | if (channel.ChannelName.ToLower() != "sfx") 64 | { 65 | if (channels.Count(x => x.Key.Value == channel.ChannelName.ToLower()) > 0) 66 | { 67 | return; 68 | } 69 | } 70 | KeyValuePair kv = new KeyValuePair(channel.Id, channel.ChannelName); 71 | lock (channels) 72 | { 73 | if (channels.All(x => x.Key.Key != channel.Id)) 74 | { 75 | channels.Add(kv, channel); 76 | } 77 | } 78 | } 79 | 80 | public void StopAll() 81 | { 82 | fmodChannelSound[] list; 83 | lock (channels) 84 | { 85 | list = channels.Select(x => x.Value).ToArray(); 86 | } 87 | foreach (var c in list) 88 | { 89 | c.Dispose(); 90 | } 91 | } 92 | 93 | 94 | public void UnregisterChannel(fmodChannelSound channel) 95 | { 96 | lock (channels) 97 | { 98 | KeyValuePair kv = new KeyValuePair(channel.Id, channel.ChannelName); 99 | channels.Remove(kv); 100 | } 101 | } 102 | 103 | public bool IsSoundPlaying(string filename) 104 | { 105 | List channelsounds = null; 106 | lock (channels) 107 | { 108 | channelsounds = channels.Values.ToList(); 109 | } 110 | foreach (var sf in channelsounds) 111 | { 112 | if (sf.SoundSoundFile != null) 113 | { 114 | if (sf.SoundSoundFile.SoundFile != null) 115 | { 116 | if (sf.SoundSoundFile.SoundFile.Filename == filename) 117 | { 118 | return true; 119 | } 120 | } 121 | } 122 | } 123 | 124 | return false; 125 | } 126 | } 127 | } 128 | 129 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Gtk; 3 | using System.IO; 4 | using NLog; 5 | 6 | namespace SoundCenSeGTK 7 | { 8 | class MainClass 9 | { 10 | private static Logger logger; 11 | 12 | public static void Main(string[] args) 13 | { 14 | if (System.IO.Path.DirectorySeparatorChar == '\\') 15 | { 16 | logger = LogManager.GetCurrentClassLogger(); 17 | if (!VCRedist120()) 18 | { 19 | logger.Fatal("Microsoft Visual C++ Redistributable 2013 is not installed."); 20 | logger.Fatal("Please download and install from https://download.microsoft.com/download/3/8/7/387A0F10-C0C1-4C74-82A9-4BB741342366/vcredist_x86.exe"); 21 | return; 22 | } 23 | if (!CheckWindowsGtk()) 24 | { 25 | logger.Fatal("GTK-Sharp is not installed."); 26 | logger.Fatal("Please download and install from http://download.xamarin.com/GTKforWindows/Windows/gtk-sharp-2.12.38.msi"); 27 | return; 28 | } 29 | } 30 | AppDomain.CurrentDomain.UnhandledException += (s, e) => 31 | { 32 | NLog.LogManager.GetCurrentClassLogger().Fatal("Uncaught Exception: " + Environment.NewLine + e.ExceptionObject + " " + e.ExceptionObject.GetType().FullName); 33 | }; 34 | Application.Init(); 35 | MainWindow win = new MainWindow(); 36 | Gtk.Settings settings = Gtk.Settings.Default; 37 | settings.SetLongProperty("gtk-button-images", 1, ""); 38 | win.Show(); 39 | Application.Run(); 40 | } 41 | 42 | static bool VCRedist120() 43 | { 44 | using (var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\DevDiv\vc\Servicing\12.0\RuntimeMinimum")) 45 | { 46 | if (key != null) 47 | { 48 | object val = key.GetValue("Install"); 49 | if (val != null) 50 | { 51 | Int32? isInstalled = (Int32?)val; 52 | if (isInstalled == 1) 53 | { 54 | { 55 | return true; 56 | } 57 | } 58 | } 59 | } 60 | } 61 | return false; 62 | } 63 | 64 | static bool CheckWindowsGtk() 65 | { 66 | logger.Warn("Checking dll in registry"); 67 | string location = null; 68 | Version version = null; 69 | Version minVersion = new Version(2, 12, 22); 70 | using (var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Xamarin\GtkSharp\InstallFolder")) 71 | { 72 | if (key != null) 73 | location = key.GetValue(null) as string; 74 | } 75 | using (var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Xamarin\GtkSharp\Version")) 76 | { 77 | if (key != null) 78 | Version.TryParse(key.GetValue(null) as string, out version); 79 | } 80 | //TODO: check build version of GTK# dlls in GAC 81 | if (version == null || version < minVersion || location == null || !System.IO.File.Exists(System.IO.Path.Combine(location, "bin", "libgtk-win32-2.0-0.dll"))) 82 | { 83 | logger.Warn("GTK# is not installed"); 84 | return false; 85 | } 86 | var path = System.IO.Path.Combine(location, @"bin"); 87 | try 88 | { 89 | if (SetDllDirectory(path)) 90 | { 91 | return true; 92 | } 93 | } 94 | catch (EntryPointNotFoundException) 95 | { 96 | } 97 | // this shouldn't happen unless something is weird in Windows 98 | return false; 99 | } 100 | 101 | [System.Runtime.InteropServices.DllImport("kernel32.dll", CharSet = System.Runtime.InteropServices.CharSet.Unicode, SetLastError = true)] 102 | [return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)] 103 | static extern bool SetDllDirectory(string lpPathName); 104 | 105 | } 106 | } -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle ("SoundCenSeGTK")] 8 | [assembly: AssemblyDescription ("Sound engine for Dwarf Fortress based on SoundSense")] 9 | [assembly: AssemblyConfiguration ("")] 10 | [assembly: AssemblyCompany ("")] 11 | [assembly: AssemblyProduct ("")] 12 | [assembly: AssemblyCopyright ("Algorithman")] 13 | [assembly: AssemblyTrademark ("")] 14 | [assembly: AssemblyCulture ("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion ("1.4.4.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | 28 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Utility/DownloadEntry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Misc; 3 | using System.Net; 4 | using System.IO; 5 | 6 | namespace SoundCenSeGTK 7 | { 8 | public class DownloadEntry : IDownloadEntry, IDisposable 9 | { 10 | #region Fields and Constants 11 | 12 | public EventHandler FinishedFile; 13 | 14 | #endregion 15 | 16 | #region Properties 17 | 18 | public string DestinationPath { get; set; } 19 | 20 | public string ExpectedSHA { get; set; } 21 | 22 | public long ExpectedSize { get; set; } 23 | 24 | public DownloadResult Result { get; set; } 25 | 26 | public string SourceURL { get; set; } 27 | 28 | public HttpStatusCode StatusCode { get; set; } 29 | 30 | public string TempFileName { get; set; } 31 | 32 | #endregion 33 | 34 | 35 | #region IDisposable Members 36 | 37 | 38 | 39 | public void Dispose() 40 | { 41 | Dispose(true); 42 | GC.SuppressFinalize(this); 43 | } 44 | 45 | #endregion 46 | 47 | private void Dispose(bool disposing) 48 | { 49 | if (disposing) 50 | { 51 | if (File.Exists(TempFileName)) 52 | { 53 | File.Delete(TempFileName); 54 | } 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Utility/XML/DirectoryData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SoundCenSeGTK 4 | { 5 | public class DirectoryData 6 | { 7 | #region Properties 8 | 9 | public string Filename { get; set; } 10 | 11 | public string RelativePath { get; set; } 12 | 13 | public string SHA1 { get; set; } 14 | 15 | public long Size { get; set; } 16 | 17 | #endregion 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/Utility/XML/UpdateParser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Security.Cryptography; 5 | using System.Xml; 6 | 7 | 8 | namespace SoundCenSeGTK 9 | { 10 | public class UpdateParser 11 | { 12 | public static List Parse(string filename) 13 | { 14 | XmlDocument doc = new XmlDocument(); 15 | TextReader tr = new StreamReader(filename); 16 | string xmldata = tr.ReadToEnd().Replace(" data = new List(); 21 | 22 | XmlNodeList nl = doc.GetElementsByTagName("autoUpdater"); 23 | XmlNode main = nl.Item(0); 24 | string relpath = ""; 25 | 26 | foreach (XmlNode dirnode in main.ChildNodes) 27 | { 28 | ParseDir(dirnode, data, relpath); 29 | } 30 | return data; 31 | } 32 | 33 | private static void ParseDir(XmlNode dirnode, List data, string relpath) 34 | { 35 | bool ignore = dirnode.ParseBoolAttribute("ignore", false); 36 | if (!ignore) 37 | { 38 | if (dirnode.LocalName == "directory") 39 | { 40 | // Recursive into subfolders 41 | string dName = dirnode.Attributes.GetNamedItem("name").Value; 42 | string relpathNew = Path.Combine(relpath, dName); 43 | foreach (XmlNode newNode in dirnode.ChildNodes) 44 | { 45 | ParseDir(newNode, data, relpathNew); 46 | } 47 | } 48 | else if (dirnode.LocalName == "file") 49 | { 50 | // Generate File data 51 | DirectoryData dd = new DirectoryData(); 52 | dd.Filename = dirnode.Attributes.GetNamedItem("name").Value; 53 | dd.RelativePath = relpath; 54 | dd.Size = dirnode.ParseLongAttribute("size", -1); 55 | dd.SHA1 = dirnode.Attributes.GetNamedItem("sha1").Value.ToLower(); 56 | data.Add(dd); 57 | } 58 | } 59 | } 60 | 61 | public static string SHA1Checksum(string filename) 62 | { 63 | string check = ""; 64 | if (!File.Exists(filename)) 65 | { 66 | return ""; 67 | } 68 | try 69 | { 70 | using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) 71 | { 72 | using (SHA1CryptoServiceProvider crypto = new SHA1CryptoServiceProvider()) 73 | { 74 | check = BitConverter.ToString(crypto.ComputeHash(fs)).Replace("-", "").ToLower(); 75 | } 76 | } 77 | } 78 | catch (Exception) 79 | { 80 | } 81 | 82 | return check; 83 | } 84 | } 85 | } 86 | 87 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/fmod.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/fmod.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe GTK/SoundCenSeGTK/fmod.dll -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/fmod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe GTK/SoundCenSeGTK/fmod.png -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/fmodstudio.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe GTK/SoundCenSeGTK/fmodstudio.dll -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/gtk-gui/generated.cs: -------------------------------------------------------------------------------- 1 | 2 | // This file has been generated by the GUI designer. Do not modify. 3 | namespace Stetic 4 | { 5 | internal class Gui 6 | { 7 | private static bool initialized; 8 | 9 | internal static void Initialize(Gtk.Widget iconRenderer) 10 | { 11 | if ((Stetic.Gui.initialized == false)) 12 | { 13 | Stetic.Gui.initialized = true; 14 | } 15 | } 16 | } 17 | 18 | internal class ActionGroups 19 | { 20 | public static Gtk.ActionGroup GetActionGroup(System.Type type) 21 | { 22 | return Stetic.ActionGroups.GetActionGroup(type.FullName); 23 | } 24 | 25 | public static Gtk.ActionGroup GetActionGroup(string name) 26 | { 27 | return null; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/libfmod.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe GTK/SoundCenSeGTK/libfmod.dylib -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/libfmod.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe GTK/SoundCenSeGTK/libfmod.so -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/libfmodstudio.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe GTK/SoundCenSeGTK/libfmodstudio.dylib -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Algorithman", 3 | "content_version": "1.4.4", 4 | "df_min_version": "0.34.11", 5 | "df_max_version": "", 6 | "title": "SoundCenSe GTK", 7 | "tooltip": "A c# audio engine for Dwarf Fortress based on Zweistein's SoundSense", 8 | "win_exe": "SoundCenSeGTK.exe", 9 | "readme": "README.html" 10 | } 11 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGTK/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGUI/MyClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SoundCenSeGUI 4 | { 5 | public class MyClass 6 | { 7 | public MyClass () 8 | { 9 | } 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGUI/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle ("SoundCenSeGUI")] 8 | [assembly: AssemblyDescription ("")] 9 | [assembly: AssemblyConfiguration ("")] 10 | [assembly: AssemblyCompany ("")] 11 | [assembly: AssemblyProduct ("")] 12 | [assembly: AssemblyCopyright ("chris")] 13 | [assembly: AssemblyTrademark ("")] 14 | [assembly: AssemblyCulture ("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion ("1.0.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | 28 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGUI/SoundCenSeGUI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | {048BAFBF-2F90-4E37-8D17-D26C71872B91} 7 | Library 8 | SoundCenSeGUI 9 | SoundCenSeGUI 10 | 1.4.2 11 | 12 | 13 | true 14 | full 15 | false 16 | bin\Debug 17 | DEBUG; 18 | prompt 19 | 4 20 | false 21 | x86 22 | 23 | 24 | false 25 | bin\Release 26 | prompt 27 | 4 28 | false 29 | x86 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | gui.stetic 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | {9805FF66-0D87-4C93-AF45-A92873446903} 58 | Misc 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGUI/SoundDisabler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Misc; 3 | 4 | namespace SoundCenSeGUI 5 | { 6 | [System.ComponentModel.ToolboxItem (true)] 7 | public partial class SoundDisabler : Gtk.Bin 8 | { 9 | private string soundName = ""; 10 | 11 | /// 12 | /// Gets or sets the name of the sound. 13 | /// 14 | /// The name of the sound. 15 | public string SoundName { 16 | get { return soundName; } 17 | set { 18 | soundName = value; 19 | labelSoundName.Text = System.IO.Path.GetFileNameWithoutExtension(value); 20 | } 21 | } 22 | 23 | /// 24 | /// The sound disabled. 25 | /// 26 | public EventHandler SoundDisabled; 27 | 28 | /// 29 | /// Initializes a new instance of the class. 30 | /// 31 | /// Sound name. 32 | public SoundDisabler (string soundName) 33 | { 34 | this.Build (); 35 | this.SoundName = soundName; 36 | ShowAll (); 37 | } 38 | 39 | protected void btnDisableClick (object sender, EventArgs e) 40 | { 41 | var handler = SoundDisabled; 42 | if (handler != null) { 43 | handler (this, new DisableSoundEventArgs (soundName)); 44 | } 45 | } 46 | } 47 | } 48 | 49 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGUI/SoundPanel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SoundCenSeGUI 4 | { 5 | [System.ComponentModel.ToolboxItem (true)] 6 | public partial class SoundPanel : Gtk.Bin 7 | { 8 | public SoundPanel () 9 | { 10 | this.Build (); 11 | } 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGUI/SoundPanelEntry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Collections.Generic; 4 | using Misc; 5 | 6 | namespace SoundCenSeGUI 7 | { 8 | [System.ComponentModel.ToolboxItem(true)] 9 | public partial class SoundPanelEntry : Gtk.Bin 10 | { 11 | private string channelName = ""; 12 | private uint length; 13 | private DateTime endTime; 14 | private double volume = 1.0f; 15 | private List disablers = new List(); 16 | 17 | public SoundPanelEntry(string channel) 18 | { 19 | this.Build(); 20 | ChannelName = channel; 21 | ShowAll(); 22 | btnFastForward.Visible = false; 23 | } 24 | 25 | public string ChannelName 26 | { 27 | get{ return channelName; } 28 | set 29 | { 30 | channelName = value; 31 | labelChannel.Text = value; 32 | } 33 | } 34 | 35 | private string filename = ""; 36 | 37 | public string Filename 38 | { 39 | get { return filename; } 40 | set 41 | { 42 | labelFile.Text = System.IO.Path.GetFileNameWithoutExtension(value); 43 | filename = value; 44 | } 45 | } 46 | 47 | public uint Length 48 | { 49 | get { return length; } 50 | set 51 | { 52 | length = value; 53 | endTime = DateTime.UtcNow + TimeSpan.FromMilliseconds(length); 54 | labelRemaining.Text = (endTime - DateTime.UtcNow).ToString("g"); 55 | } 56 | } 57 | 58 | public double Volume 59 | { 60 | get{ return volume; } 61 | set 62 | { 63 | volumeScale.Value = value; 64 | volume = value; 65 | } 66 | } 67 | 68 | public void AddEntry(string filename) 69 | { 70 | if (!string.IsNullOrEmpty(filename.Trim())) 71 | { 72 | SoundDisabler sd = new SoundDisabler(filename.Trim()); 73 | sd.SoundDisabled += SoundDisabledInternal; 74 | disablers.Add(sd); 75 | DisablerTable.PackEnd(sd); 76 | sd.Show(); 77 | if (disablers.Count > 5) 78 | { 79 | SoundDisabler toRemove = disablers[0]; 80 | disablers.RemoveAt(0); 81 | toRemove.Destroy(); 82 | } 83 | } 84 | } 85 | 86 | public EventHandler SoundDisabled; 87 | 88 | private void SoundDisabledInternal(object sender, DisableSoundEventArgs e) 89 | { 90 | var handler = SoundDisabled; 91 | if (handler != null) 92 | { 93 | handler(sender, e); 94 | } 95 | } 96 | 97 | protected void btnFastForwardClicked(object sender, EventArgs e) 98 | { 99 | OnFastForward(); 100 | } 101 | 102 | public EventHandler ChannelFastForward; 103 | 104 | protected virtual void OnFastForward() 105 | { 106 | var handler = ChannelFastForward; 107 | if (handler != null) 108 | { 109 | handler(this, new ChannelFastForwardEventArgs(channelName)); 110 | } 111 | } 112 | 113 | public EventHandler ChannelMute; 114 | 115 | protected virtual void OnChannelMute() 116 | { 117 | var handler = ChannelMute; 118 | if (handler != null) 119 | { 120 | handler(this, new ChannelMuteEventArgs(channelName, btnMute.Active)); 121 | } 122 | } 123 | 124 | protected void btnChannelMuteClick(object sender, EventArgs e) 125 | { 126 | OnChannelMute(); 127 | } 128 | 129 | public void Tick() 130 | { 131 | if (endTime > DateTime.UtcNow) 132 | { 133 | labelRemaining.Text = (endTime - DateTime.UtcNow).ToString("mm\\:ss\\.f"); 134 | } 135 | else 136 | { 137 | labelRemaining.Text = ""; 138 | labelFile.Text = ""; 139 | } 140 | } 141 | 142 | 143 | public EventHandler VolumeChanged; 144 | 145 | protected virtual void OnVolumeChanged() 146 | { 147 | double value = volumeScale.Value; 148 | volume = value; 149 | 150 | var handler = VolumeChanged; 151 | if (handler != null) 152 | { 153 | handler(this, new VolumeChangedEventArgs(channelName, value)); 154 | } 155 | } 156 | 157 | private bool mute = false; 158 | 159 | public bool Mute 160 | { 161 | get{ return mute; } 162 | set 163 | { 164 | mute = value; 165 | btnMute.Active = value; 166 | } 167 | } 168 | 169 | public void SetValues(string filename, uint soundLength, bool muted, double volume, bool looping) 170 | { 171 | Gtk.Application.Invoke(delegate 172 | { 173 | Filename = filename; 174 | Length = soundLength; 175 | Volume = volume; 176 | Mute = muted; 177 | btnFastForward.Visible = looping; 178 | AddEntry(filename); 179 | }); 180 | } 181 | 182 | protected void btnMuteClicked(object sender, EventArgs e) 183 | { 184 | OnChannelMute(); 185 | } 186 | 187 | protected void SliderMoved(object sender, EventArgs e) 188 | { 189 | OnVolumeChanged(); 190 | } 191 | } 192 | } 193 | 194 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGUI/gtk-gui/SoundCenSeGUI.SoundDisabler.cs: -------------------------------------------------------------------------------- 1 | 2 | // This file has been generated by the GUI designer. Do not modify. 3 | namespace SoundCenSeGUI 4 | { 5 | public partial class SoundDisabler 6 | { 7 | private global::Gtk.HBox hbox1; 8 | 9 | private global::Gtk.Button button1; 10 | 11 | private global::Gtk.Label labelSoundName; 12 | 13 | protected virtual void Build () 14 | { 15 | global::Stetic.Gui.Initialize (this); 16 | // Widget SoundCenSeGUI.SoundDisabler 17 | global::Stetic.BinContainer.Attach (this); 18 | this.Name = "SoundCenSeGUI.SoundDisabler"; 19 | // Container child SoundCenSeGUI.SoundDisabler.Gtk.Container+ContainerChild 20 | this.hbox1 = new global::Gtk.HBox (); 21 | this.hbox1.Name = "hbox1"; 22 | this.hbox1.Spacing = 6; 23 | // Container child hbox1.Gtk.Box+BoxChild 24 | this.button1 = new global::Gtk.Button (); 25 | this.button1.WidthRequest = 24; 26 | this.button1.Name = "button1"; 27 | this.button1.UseUnderline = true; 28 | this.button1.FocusOnClick = false; 29 | global::Gtk.Image w1 = new global::Gtk.Image (); 30 | w1.Pixbuf = global::Gdk.Pixbuf.LoadFromResource ("SoundCenSeGUI.DisableSound 15x15.png"); 31 | this.button1.Image = w1; 32 | this.hbox1.Add (this.button1); 33 | global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.button1])); 34 | w2.Position = 0; 35 | w2.Expand = false; 36 | w2.Fill = false; 37 | // Container child hbox1.Gtk.Box+BoxChild 38 | this.labelSoundName = new global::Gtk.Label (); 39 | this.labelSoundName.Name = "labelSoundName"; 40 | this.labelSoundName.LabelProp = "label7"; 41 | this.hbox1.Add (this.labelSoundName); 42 | global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.labelSoundName])); 43 | w3.Position = 1; 44 | w3.Expand = false; 45 | w3.Fill = false; 46 | this.Add (this.hbox1); 47 | if ((this.Child != null)) { 48 | this.Child.ShowAll (); 49 | } 50 | this.Show (); 51 | this.button1.Clicked += new global::System.EventHandler (this.btnDisableClick); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /SoundCenSe GTK/SoundCenSeGUI/gtk-gui/generated.cs: -------------------------------------------------------------------------------- 1 | 2 | // This file has been generated by the GUI designer. Do not modify. 3 | namespace Stetic 4 | { 5 | internal class Gui 6 | { 7 | private static bool initialized; 8 | 9 | internal static void Initialize (Gtk.Widget iconRenderer) 10 | { 11 | if ((Stetic.Gui.initialized == false)) { 12 | Stetic.Gui.initialized = true; 13 | global::Gtk.IconFactory w1 = new global::Gtk.IconFactory (); 14 | global::Gtk.IconSet w2 = new global::Gtk.IconSet (global::Gdk.Pixbuf.LoadFromResource ("SoundCenSeGUI.DisableSound 15x15.png")); 15 | w1.Add ("DisableSound", w2); 16 | w1.AddDefault (); 17 | } 18 | } 19 | } 20 | 21 | internal class BinContainer 22 | { 23 | private Gtk.Widget child; 24 | 25 | private Gtk.UIManager uimanager; 26 | 27 | public static BinContainer Attach (Gtk.Bin bin) 28 | { 29 | BinContainer bc = new BinContainer (); 30 | bin.SizeRequested += new Gtk.SizeRequestedHandler (bc.OnSizeRequested); 31 | bin.SizeAllocated += new Gtk.SizeAllocatedHandler (bc.OnSizeAllocated); 32 | bin.Added += new Gtk.AddedHandler (bc.OnAdded); 33 | return bc; 34 | } 35 | 36 | private void OnSizeRequested (object sender, Gtk.SizeRequestedArgs args) 37 | { 38 | if ((this.child != null)) { 39 | args.Requisition = this.child.SizeRequest (); 40 | } 41 | } 42 | 43 | private void OnSizeAllocated (object sender, Gtk.SizeAllocatedArgs args) 44 | { 45 | if ((this.child != null)) { 46 | this.child.Allocation = args.Allocation; 47 | } 48 | } 49 | 50 | private void OnAdded (object sender, Gtk.AddedArgs args) 51 | { 52 | this.child = args.Widget; 53 | } 54 | 55 | public void SetUiManager (Gtk.UIManager uim) 56 | { 57 | this.uimanager = uim; 58 | this.child.Realized += new System.EventHandler (this.OnRealized); 59 | } 60 | 61 | private void OnRealized (object sender, System.EventArgs args) 62 | { 63 | if ((this.uimanager != null)) { 64 | Gtk.Widget w; 65 | w = this.child.Toplevel; 66 | if (((w != null) 67 | && typeof(Gtk.Window).IsInstanceOfType (w))) { 68 | ((Gtk.Window)(w)).AddAccelGroup (this.uimanager.AccelGroup); 69 | this.uimanager = null; 70 | } 71 | } 72 | } 73 | } 74 | 75 | internal class ActionGroups 76 | { 77 | public static Gtk.ActionGroup GetActionGroup (System.Type type) 78 | { 79 | return Stetic.ActionGroups.GetActionGroup (type.FullName); 80 | } 81 | 82 | public static Gtk.ActionGroup GetActionGroup (string name) 83 | { 84 | return null; 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /SoundCenSe GTK/buildOSX.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -o nuget.exe 4 | mono --runtime=v4.0 nuget.exe restore 5 | mono --runtime=v4.0 nuget install Mono.Posix 6 | xbuild 7 | -------------------------------------------------------------------------------- /SoundCenSe WinForms/ArrowDown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe WinForms/ArrowDown.png -------------------------------------------------------------------------------- /SoundCenSe WinForms/ArrowUp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe WinForms/ArrowUp.png -------------------------------------------------------------------------------- /SoundCenSe WinForms/DisableSound 15x15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe WinForms/DisableSound 15x15.png -------------------------------------------------------------------------------- /SoundCenSe WinForms/FastForward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe WinForms/FastForward.png -------------------------------------------------------------------------------- /SoundCenSe WinForms/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Algorithman 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 | -------------------------------------------------------------------------------- /SoundCenSe WinForms/Mute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe WinForms/Mute.png -------------------------------------------------------------------------------- /SoundCenSe WinForms/Program.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe WinForms/Program.ico -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SoundCenSe", "SoundCenSe\SoundCenSe.csproj", "{2C19650D-0695-4619-9913-FA1839D2FE08}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {2C19650D-0695-4619-9913-FA1839D2FE08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {2C19650D-0695-4619-9913-FA1839D2FE08}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {2C19650D-0695-4619-9913-FA1839D2FE08}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {2C19650D-0695-4619-9913-FA1839D2FE08}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Config.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: Config.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using NLog; 11 | using SoundCenSe.Configuration; 12 | 13 | namespace SoundCenSe 14 | { 15 | public class Config 16 | { 17 | #region Fields and Constants 18 | 19 | public static ConfigurationData Instance; 20 | private static Logger logger = LogManager.GetCurrentClassLogger(); 21 | 22 | #endregion 23 | 24 | public Config(string filename) 25 | { 26 | Load(filename); 27 | } 28 | 29 | public static void Load(string filename) 30 | { 31 | Instance = ConfigurationData.Load(filename); 32 | } 33 | 34 | public static void Save(string filename) 35 | { 36 | Instance.Save(filename); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "achievements": false, 3 | "allowPackOverride": true, 4 | "autoUpdateURLs": [ 5 | "http://df.zweistein.cz/soundsense/soundpack", 6 | "http://www.armedassault.info/_hosted/soundsense/au" 7 | ], 8 | "Channels": [ 9 | { 10 | "Channel": "weather", 11 | "Mute": false, 12 | "Volume": 1.0 13 | }, 14 | { 15 | "Channel": "music", 16 | "Mute": false, 17 | "Volume": 1.0 18 | }, 19 | { 20 | "Channel": "swords", 21 | "Mute": false, 22 | "Volume": 1.0 23 | }, 24 | { 25 | "Channel": "trade", 26 | "Mute": false, 27 | "Volume": 1.0 28 | }, 29 | { 30 | "Channel": "sfx", 31 | "Mute": false, 32 | "Volume": 1.0 33 | } 34 | ], 35 | "deleteFiles": true, 36 | "disabledSounds": [], 37 | "expectedMinimalSoundsCound": 0, 38 | "gamelogEncoding": "Cp850", 39 | "gamelogPath": "../df_linux/gamelog.txt", 40 | "gui": true, 41 | "mutedChannels": [], 42 | "noWarnAbsolutePaths": false, 43 | "playbackThreshold": 4, 44 | "replaceFiles": true, 45 | "soundpacksPath": "./packs/", 46 | "supplementalLogs": [], 47 | "volume": 0.0 48 | } 49 | -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Configuration/ChannelData.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: ChannelData.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | namespace SoundCenSe.Configuration 11 | { 12 | public class ChannelData 13 | { 14 | #region Properties 15 | 16 | public string Channel { get; set; } 17 | public bool Mute { get; set; } 18 | public float Volume { get; set; } 19 | 20 | #endregion 21 | } 22 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Configuration/ConfigurationData.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: ConfigurationData.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System.Collections.Generic; 11 | using System.IO; 12 | using System.Linq; 13 | using Newtonsoft.Json; 14 | using SoundCenSe.Enums; 15 | 16 | namespace SoundCenSe.Configuration 17 | { 18 | public class ConfigurationData 19 | { 20 | #region Properties 21 | 22 | public bool achievements { get; set; } 23 | public bool allowPackOverride { get; set; } 24 | public List autoUpdateURLs { get; set; } 25 | public List Channels { get; set; } 26 | public bool deleteFiles { get; set; } 27 | public HashSet disabledSounds { get; set; } 28 | public long expectedMinimalSoundsCound { get; set; } 29 | 30 | public string fileName { get; set; } 31 | public string gamelogEncoding { get; set; } 32 | public string gamelogPath { get; set; } 33 | public bool gui { get; set; } 34 | public HashSet mutedChannels { get; set; } 35 | public bool noWarnAbsolutePaths { get; set; } 36 | public Threshold playbackThreshold { get; set; } 37 | public bool replaceFiles { get; set; } 38 | public string soundpacksPath { get; set; } 39 | public List supplementalLogs { get; set; } 40 | public float volume { get; set; } 41 | 42 | #endregion 43 | 44 | public ConfigurationData() 45 | { 46 | autoUpdateURLs = new List(); 47 | disabledSounds = new HashSet(); 48 | mutedChannels = new HashSet(); 49 | supplementalLogs = new List(); 50 | Channels = new List(); 51 | } 52 | 53 | public ChannelData GetChannelData(string channel) 54 | { 55 | ChannelData cx = Channels.FirstOrDefault(x => x.Channel == channel); 56 | if (cx == null) 57 | { 58 | // Dummy if not in list 59 | cx = new ChannelData(); 60 | cx.Volume = 1.0f; 61 | cx.Mute = false; 62 | cx.Channel = ""; 63 | } 64 | return cx; 65 | } 66 | 67 | public static ConfigurationData Load(string filename) 68 | { 69 | using (TextReader tr = new StreamReader(filename)) 70 | { 71 | return JsonConvert.DeserializeObject(tr.ReadToEnd()); 72 | } 73 | } 74 | 75 | public void MuteChannel(string channel, bool mute) 76 | { 77 | foreach (ChannelData cd in Channels) 78 | { 79 | if (cd.Channel == channel) 80 | { 81 | cd.Mute = mute; 82 | return; 83 | } 84 | } 85 | ChannelData cdNew = new ChannelData(); 86 | cdNew.Channel = channel; 87 | cdNew.Mute = mute; 88 | cdNew.Volume = 1.0f; 89 | Channels.Add(cdNew); 90 | } 91 | 92 | public void Save(string filename) 93 | { 94 | using (TextWriter tw = new StreamWriter(filename)) 95 | { 96 | tw.WriteLine(JsonConvert.SerializeObject(this, Formatting.Indented)); 97 | } 98 | } 99 | 100 | public void SetChannelVolume(string channel, float vol) 101 | { 102 | foreach (ChannelData cd in Channels) 103 | { 104 | if (cd.Channel == channel) 105 | { 106 | cd.Volume = vol; 107 | return; 108 | } 109 | } 110 | ChannelData cdNew = new ChannelData(); 111 | cdNew.Channel = channel; 112 | cdNew.Mute = false; 113 | cdNew.Volume = vol; 114 | Channels.Add(cdNew); 115 | } 116 | } 117 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Configuration/Constants.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: Constants.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | namespace SoundCenSe.Configuration 11 | { 12 | public static class Constants 13 | { 14 | #region Fields and Constants 15 | 16 | public const int AudioChannels = 2; 17 | public const int Samplerate = 44100; 18 | 19 | #endregion 20 | } 21 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Configuration/Sounds/Attribution.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: Attribution.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | #region Usings 11 | 12 | using System.Xml; 13 | using NLog; 14 | 15 | #endregion 16 | 17 | namespace SoundCenSe.Configuration.Sounds 18 | { 19 | public class Attribution 20 | { 21 | #region Fields and Constants 22 | 23 | private static readonly Logger logger = LogManager.GetCurrentClassLogger(); 24 | 25 | #endregion 26 | 27 | #region Properties 28 | 29 | public string Author { get; set; } 30 | public string Description { get; set; } 31 | public string License { get; set; } 32 | public string Note { get; set; } 33 | 34 | public string Url { get; set; } 35 | 36 | #endregion 37 | 38 | public Attribution(string url, string license, string author, string description, string note) 39 | { 40 | Url = url; 41 | License = license; 42 | Author = author; 43 | Description = description; 44 | Note = note; 45 | } 46 | 47 | public static Attribution ReadFromXML(XmlNode node, SoundFile soundfile) 48 | { 49 | string url = node.ParseStringAttribute("url", null); 50 | string license = node.ParseStringAttribute("license", null); 51 | string author = node.ParseStringAttribute("author", null); 52 | string description = node.ParseStringAttribute("description", null); 53 | string note = node.ParseStringAttribute("note", ""); 54 | 55 | if (string.IsNullOrEmpty(url)) 56 | { 57 | logger.Info("Attribution url is not set for " + soundfile.Filename); 58 | return null; 59 | } 60 | if (string.IsNullOrEmpty(license)) 61 | { 62 | logger.Info("Attribution license is not set for " + soundfile.Filename); 63 | return null; 64 | } 65 | if (string.IsNullOrEmpty(author)) 66 | { 67 | logger.Info("Attribution author is not set for " + soundfile.Filename); 68 | return null; 69 | } 70 | return new Attribution(url, license, author, description, note); 71 | } 72 | 73 | public override string ToString() 74 | { 75 | return Url; 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Configuration/Sounds/Playlist/IPlaylistParser.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: IPlaylistParser.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | #region Usings 11 | 12 | using System.Collections.Generic; 13 | using System.IO; 14 | 15 | #endregion 16 | 17 | namespace SoundCenSe.Configuration.Sounds.Playlist 18 | { 19 | public interface IPlaylistParser 20 | { 21 | /// 22 | /// Parse the playlist file 23 | /// 24 | /// Name of the parent XML file 25 | /// Input stream of the playlist file 26 | /// List of audio file names 27 | List Parse(string parentFilename, Stream input); 28 | } 29 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Configuration/Sounds/Playlist/M3UParser.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: M3UParser.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | #region Usings 11 | 12 | using System; 13 | using System.Collections.Generic; 14 | using System.IO; 15 | using NLog; 16 | 17 | #endregion 18 | 19 | namespace SoundCenSe.Configuration.Sounds.Playlist 20 | { 21 | /// 22 | /// Parser for M3U playlists 23 | /// 24 | public class M3UParser : IPlaylistParser 25 | { 26 | #region Fields and Constants 27 | 28 | private static readonly Logger logger = LogManager.GetCurrentClassLogger(); 29 | 30 | #endregion 31 | 32 | #region IPlaylistParser Members 33 | 34 | /// 35 | /// Parse M3U file stream 36 | /// 37 | /// Name of the parent XML file 38 | /// Input stream of the playlist 39 | /// List of audio file names 40 | public List Parse(string parentFilename, Stream input) 41 | { 42 | List playlist = new List(); 43 | 44 | TextReader tr = new StreamReader(input); 45 | string line = tr.ReadLine(); 46 | 47 | if (line == "#EXTM3U") 48 | { 49 | while (line != null) 50 | { 51 | if (!line.StartsWith("#") && !string.IsNullOrEmpty(line)) 52 | { 53 | string soundFilename = Path.Combine(Path.GetDirectoryName(parentFilename), line); 54 | if (!File.Exists(soundFilename)) 55 | { 56 | if (File.Exists(line)) 57 | { 58 | soundFilename = line; 59 | } 60 | else 61 | { 62 | logger.Warn("Did not find " + soundFilename + ", ignoring."); 63 | soundFilename = null; 64 | } 65 | } 66 | if (!string.IsNullOrEmpty(soundFilename)) 67 | { 68 | playlist.Add(soundFilename); 69 | } 70 | } 71 | line = tr.ReadLine(); 72 | } 73 | } 74 | else 75 | { 76 | throw new Exception("Wrong header for playlist"); 77 | } 78 | 79 | return playlist; 80 | } 81 | 82 | #endregion 83 | } 84 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Configuration/Sounds/Playlist/PLSParser.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: PLSParser.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | #region Usings 11 | 12 | using System; 13 | using System.Collections.Generic; 14 | using System.IO; 15 | using NLog; 16 | 17 | #endregion 18 | 19 | namespace SoundCenSe.Configuration.Sounds.Playlist 20 | { 21 | /// 22 | /// Parser for PLS playlists 23 | /// 24 | public class PLSParser : IPlaylistParser 25 | { 26 | #region Fields and Constants 27 | 28 | private static readonly Logger logger = LogManager.GetCurrentClassLogger(); 29 | 30 | #endregion 31 | 32 | #region IPlaylistParser Members 33 | 34 | /// 35 | /// Parse PLS file stream 36 | /// 37 | /// Name of the parent XML file 38 | /// Input stream of the playlist 39 | /// List of audio file names 40 | public List Parse(string parentFilename, Stream input) 41 | { 42 | List playlist = new List(); 43 | TextReader tr = new StreamReader(input); 44 | 45 | string line = tr.ReadLine(); 46 | 47 | if (line == "[playlist]") 48 | { 49 | while (line != null) 50 | { 51 | if (line.StartsWith("File")) 52 | { 53 | string[] fileparts = line.Split('='); 54 | string soundFilename = Path.Combine(Path.GetDirectoryName(parentFilename), fileparts[1]); 55 | if (!File.Exists(soundFilename)) 56 | { 57 | if (File.Exists(fileparts[1])) 58 | { 59 | soundFilename = fileparts[1]; 60 | } 61 | else 62 | { 63 | logger.Warn("Did not find " + soundFilename + ", ignoring."); 64 | soundFilename = null; 65 | } 66 | } 67 | if (!string.IsNullOrEmpty(soundFilename)) 68 | { 69 | playlist.Add(soundFilename); 70 | } 71 | } 72 | line = tr.ReadLine(); 73 | } 74 | } 75 | else 76 | { 77 | throw new Exception("Wrong header for playlist"); 78 | } 79 | return playlist; 80 | } 81 | 82 | #endregion 83 | } 84 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Configuration/Sounds/RepeatSound.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: RepeatSound.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System.Collections.Generic; 11 | using SoundCenSe.Enums; 12 | 13 | namespace SoundCenSe.Configuration.Sounds 14 | { 15 | public class RepeatSound : Sound 16 | { 17 | public RepeatSound(string parentFile, List soundfiles, string pattern, string ansiFormat, Loop _loop, 18 | string channel, long concurrency, bool haltOnMatch, long timeout, long delay, long probability, 19 | long playbackThreshold) 20 | : base( 21 | parentFile, soundfiles, pattern, ansiFormat, _loop, channel, concurrency, haltOnMatch, timeout, delay, 22 | probability, playbackThreshold) 23 | { 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Configuration/Sounds/Sound.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: Sound.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | #region Usings 11 | 12 | using System; 13 | using System.Collections.Generic; 14 | using System.Linq; 15 | using System.Text.RegularExpressions; 16 | using SoundCenSe.Enums; 17 | 18 | #endregion 19 | 20 | namespace SoundCenSe.Configuration.Sounds 21 | { 22 | public class Sound : IDisposable 23 | { 24 | #region Fields and Constants 25 | 26 | public List SoundFiles = new List(); 27 | 28 | #endregion 29 | 30 | #region Properties 31 | 32 | public string AnsiFormat { get; set; } 33 | public string Channel { get; set; } 34 | public long Concurrency { get; set; } 35 | public long Delay { get; set; } 36 | public bool HaltOnMatch { get; set; } 37 | public long Hits { get; set; } 38 | public long LastPlayed { get; set; } 39 | public string logPattern { get; set; } 40 | public Loop loop { get; set; } 41 | public string ParentFile { get; set; } 42 | public Regex parsedPattern { get; set; } 43 | public long PlaybackThreshold { get; set; } 44 | public long Probability { get; set; } 45 | 46 | public int SoundFilesWeightSum { get; set; } 47 | public long Timeout { get; set; } 48 | 49 | #endregion 50 | 51 | public Sound(string parentFile, List soundfiles, string pattern, string ansiFormat, Loop _loop, 52 | string channel, long concurrency, bool haltOnMatch, long timeout, long delay, long probability, 53 | long playbackThreshold) 54 | { 55 | ParentFile = parentFile; 56 | if (soundfiles != null) 57 | { 58 | SoundFiles.AddRange(soundfiles.OrderByDescending(x => x.Weight).ToArray()); 59 | } 60 | logPattern = pattern; 61 | loop = _loop; 62 | Channel = channel; 63 | Concurrency = concurrency; 64 | HaltOnMatch = haltOnMatch; 65 | Hits = 0; 66 | Probability = probability; 67 | PlaybackThreshold = playbackThreshold; 68 | AnsiFormat = ansiFormat; 69 | SoundFilesWeightSum = 0; 70 | Delay = delay; 71 | Timeout = timeout; 72 | foreach (SoundFile sf in SoundFiles) 73 | { 74 | SoundFilesWeightSum += sf.Weight; 75 | } 76 | 77 | if (!string.IsNullOrEmpty(logPattern)) 78 | { 79 | parsedPattern = new Regex(logPattern); 80 | } 81 | } 82 | 83 | #region IDisposable Members 84 | 85 | public void Dispose() 86 | { 87 | Dispose(true); 88 | GC.SuppressFinalize(this); 89 | } 90 | 91 | #endregion 92 | 93 | private void Dispose(bool disposing) 94 | { 95 | if (disposing) 96 | { 97 | foreach (SoundFile sf in SoundFiles) 98 | { 99 | sf.Dispose(); 100 | } 101 | } 102 | } 103 | 104 | public SoundFile GetRandomSoundFile() 105 | { 106 | int disabled = SoundFiles.Count(x => x.Disabled); 107 | if ((SoundFiles.Count > 0) && (disabled < SoundFiles.Count)) 108 | { 109 | int weightSum = SoundFilesWeightSum; 110 | if (disabled > 0) 111 | { 112 | foreach (SoundFile sf in SoundFiles.Where(x => x.Disabled)) 113 | { 114 | weightSum -= sf.Weight; 115 | } 116 | } 117 | Random rnd = new Random(); 118 | int weightedrandom = rnd.Next(weightSum); 119 | foreach (SoundFile sf in SoundFiles.Where(x => !x.Disabled)) 120 | { 121 | if (sf.Weight > weightedrandom) 122 | { 123 | return sf; 124 | } 125 | weightedrandom -= sf.Weight; 126 | } 127 | } 128 | return null; 129 | } 130 | 131 | public bool HasNoSoundFiles() 132 | { 133 | return SoundFiles.Count == 0; 134 | } 135 | 136 | public void Hit() 137 | { 138 | Hits++; 139 | } 140 | 141 | public bool Matches(string line) 142 | { 143 | return parsedPattern.IsMatch(line); 144 | } 145 | 146 | public override string ToString() 147 | { 148 | return ParentFile; 149 | } 150 | } 151 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Configuration/Sounds/SoundFile.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: SoundFile.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | #region Usings 11 | 12 | using System; 13 | using System.Collections.Generic; 14 | 15 | #endregion 16 | 17 | namespace SoundCenSe.Configuration.Sounds 18 | { 19 | public class SoundFile : IDisposable 20 | { 21 | #region Fields and Constants 22 | 23 | public List Attributions = new List(); 24 | public int Weight = 100; 25 | 26 | #endregion 27 | 28 | #region Properties 29 | 30 | public float BalanceAdjustment { get; set; } 31 | 32 | public bool Disabled { get; set; } 33 | 34 | public string Filename { get; set; } 35 | 36 | public uint Length { get; set; } 37 | public bool RandomBalance { get; set; } 38 | public float VolumeAdjustment { get; set; } 39 | 40 | #endregion 41 | 42 | public SoundFile(string filename, int weight, float volumeAdjustment, float balanceAdjustment, 43 | bool randomBalance) 44 | { 45 | Filename = filename; 46 | Weight = weight; 47 | VolumeAdjustment = volumeAdjustment; 48 | BalanceAdjustment = balanceAdjustment; 49 | RandomBalance = randomBalance; 50 | } 51 | 52 | #region IDisposable Members 53 | 54 | public void Dispose() 55 | { 56 | Dispose(true); 57 | GC.SuppressFinalize(this); 58 | } 59 | 60 | #endregion 61 | 62 | private void Dispose(bool disposing) 63 | { 64 | if (disposing) 65 | { 66 | } 67 | } 68 | 69 | public override string ToString() 70 | { 71 | return Filename; 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Configuration/XmlExtensions.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: XmlExtensions.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | #region Usings 11 | 12 | using System.Collections.Generic; 13 | using System.Xml; 14 | using NLog; 15 | 16 | #endregion 17 | 18 | namespace SoundCenSe.Configuration 19 | { 20 | public static class XmlExtensions 21 | { 22 | #region Fields and Constants 23 | 24 | private static readonly Logger logger = LogManager.GetCurrentClassLogger(); 25 | 26 | #endregion 27 | 28 | public static bool ParseBoolAttribute(this XmlNode node, string attributeName, bool defaultValue) 29 | { 30 | bool result = defaultValue; 31 | XmlNode boolNode = node.Attributes.GetNamedItem(attributeName); 32 | if (boolNode != null) 33 | { 34 | if (boolNode.Value.Equals("true")) 35 | { 36 | result = true; 37 | } 38 | else if (boolNode.Value.Equals("false")) 39 | { 40 | result = false; 41 | } 42 | else 43 | { 44 | logger.Warn("XML Warning: " + attributeName + "'s value is not recognized, using default value " + 45 | defaultValue); 46 | } 47 | } 48 | return result; 49 | } 50 | 51 | public static bool ParseBooleanTag(this XmlElement element, string nodeName) 52 | { 53 | XmlNode node = element.GetElementsByTagName(nodeName).Item(0); 54 | return node.ParseBoolAttribute("value", true); 55 | } 56 | 57 | public static float ParseFloatAttribute(this XmlNode node, string attributeName, float defaultValue) 58 | { 59 | float result = defaultValue; 60 | XmlNode floatNode = node.Attributes.GetNamedItem(attributeName); 61 | if (floatNode != null) 62 | { 63 | string text = floatNode.Value; 64 | if (!float.TryParse(text, out result)) 65 | { 66 | logger.Warn("XML Warning: " + attributeName + "'s value is not recognized, using default value " + 67 | defaultValue); 68 | } 69 | } 70 | return result; 71 | } 72 | 73 | public static int ParseIntAttribute(this XmlNode node, string attributeName, int defaultValue) 74 | { 75 | int result = defaultValue; 76 | XmlNode intNode = node.Attributes.GetNamedItem(attributeName); 77 | if (intNode != null) 78 | { 79 | string text = intNode.Value; 80 | if (!int.TryParse(text, out result)) 81 | { 82 | logger.Warn("XML Warning: " + attributeName + "'s value is not recognized, using default value " + 83 | defaultValue); 84 | } 85 | } 86 | return result; 87 | } 88 | 89 | public static long ParseLongAttribute(this XmlNode node, string attributeName, long defaultValue) 90 | { 91 | long result = defaultValue; 92 | XmlNode longNode = node.Attributes.GetNamedItem(attributeName); 93 | if (longNode != null) 94 | { 95 | string text = longNode.Value; 96 | if (!long.TryParse(text, out result)) 97 | { 98 | logger.Warn("XML Warning: " + attributeName + "'s value is not recognized, using default value " + 99 | defaultValue); 100 | } 101 | } 102 | return result; 103 | } 104 | 105 | public static List ParsePathList(this XmlNode node) 106 | { 107 | List list = new List(); 108 | 109 | XmlNodeList items = node.ChildNodes; 110 | foreach (XmlNode n in items) 111 | { 112 | string name = n.LocalName; 113 | if (name == "item") 114 | { 115 | list.Add(n.Attributes.GetNamedItem("path").Value); 116 | } 117 | } 118 | return list; 119 | } 120 | 121 | public static string ParseStringAttribute(this XmlNode node, string attributeName, string defaultValue) 122 | { 123 | string result = defaultValue; 124 | XmlNode stringNode = node.Attributes.GetNamedItem(attributeName); 125 | if (stringNode != null) 126 | { 127 | result = stringNode.Value; 128 | } 129 | return result; 130 | } 131 | } 132 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Enums/Loop.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: Loop.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | namespace SoundCenSe.Enums 11 | { 12 | public enum Loop 13 | { 14 | Start_Looping, 15 | Stop_Looping 16 | } 17 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Enums/Threshold.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: Threshold.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | namespace SoundCenSe.Enums 11 | { 12 | public enum Threshold : long 13 | { 14 | Everything = 4, 15 | Fluffy = 3, 16 | Important = 2, 17 | Critical = 1, 18 | Nothing = 0 19 | } 20 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Events/ChannelFastForwardEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: ChannelFastForwardEventArgs.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | 12 | namespace SoundCenSe.Events 13 | { 14 | public class ChannelFastForwardEventArgs : EventArgs 15 | { 16 | #region Properties 17 | 18 | public string Channel { get; set; } 19 | 20 | #endregion 21 | 22 | public ChannelFastForwardEventArgs(string channel) 23 | { 24 | Channel = channel; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Events/ChannelMuteEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: ChannelMuteEventArgs.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | 12 | namespace SoundCenSe.Events 13 | { 14 | public class ChannelMuteEventArgs : EventArgs 15 | { 16 | #region Properties 17 | 18 | public string Channel { get; set; } 19 | 20 | public bool Mute { get; set; } 21 | 22 | #endregion 23 | 24 | public ChannelMuteEventArgs(string channel, bool mute) 25 | { 26 | Channel = channel; 27 | Mute = mute; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Events/ChannelVolumeEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: ChannelVolumeEventArgs.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | 12 | namespace SoundCenSe.Events 13 | { 14 | public class ChannelVolumeEventArgs : EventArgs 15 | { 16 | #region Properties 17 | 18 | public string Channel { get; set; } 19 | public float Volume { get; set; } 20 | 21 | #endregion 22 | 23 | public ChannelVolumeEventArgs(string channel, float volume) 24 | { 25 | Channel = channel; 26 | Volume = volume; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Events/DisableSoundEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: DisableSoundEventArgs.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | 12 | namespace SoundCenSe.Events 13 | { 14 | public class DisableSoundEventArgs : EventArgs 15 | { 16 | #region Properties 17 | 18 | public bool Disable { get; set; } 19 | public string Filename { get; set; } 20 | 21 | #endregion 22 | 23 | public DisableSoundEventArgs(string filename, bool disable) 24 | { 25 | Filename = filename; 26 | Disable = disable; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Events/DownloadFinishedEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: DownloadFinishedEventArgs.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | #region Usings 11 | 12 | using System; 13 | using SoundCenSe.Utility.Updater; 14 | 15 | #endregion 16 | 17 | namespace SoundCenSe.Events 18 | { 19 | public class DownloadFinishedEventArgs : EventArgs 20 | { 21 | #region Properties 22 | 23 | public DownloadEntry File { get; set; } 24 | 25 | #endregion 26 | 27 | public DownloadFinishedEventArgs(DownloadEntry file) 28 | { 29 | File = file; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Events/DwarfFortressRunningEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: DwarfFortressRunningEventArgs.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | 12 | namespace SoundCenSe.Events 13 | { 14 | public class DwarfFortressRunningEventArgs : EventArgs 15 | { 16 | #region Properties 17 | 18 | public int ProcessId { get; set; } 19 | 20 | #endregion 21 | 22 | public DwarfFortressRunningEventArgs(int processId) 23 | { 24 | ProcessId = processId; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Events/DwarfFortressStoppedEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: DwarfFortressStoppedEventArgs.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | 12 | namespace SoundCenSe.Events 13 | { 14 | public class DwarfFortressStoppedEventArgs : EventArgs 15 | { 16 | } 17 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Events/GamelogEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: GamelogEventArgs.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | 12 | namespace SoundCenSe.Events 13 | { 14 | public class GamelogEventArgs : EventArgs 15 | { 16 | #region Properties 17 | 18 | public string Line { get; set; } 19 | 20 | #endregion 21 | 22 | public GamelogEventArgs(string line) 23 | { 24 | Line = line; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Events/InitProgressBarEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: InitProgressBarEventArgs.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | 12 | namespace SoundCenSe.Events 13 | { 14 | public class InitProgressBarEventArgs : EventArgs 15 | { 16 | #region Properties 17 | 18 | public int Maximum { get; set; } 19 | 20 | #endregion 21 | 22 | public InitProgressBarEventArgs(int maximum) 23 | { 24 | Maximum = maximum; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Events/RestartSoundLoopEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: RestartSoundLoopEventArgs.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | using SoundCenSe.fmodInternal; 12 | 13 | namespace SoundCenSe.Events 14 | { 15 | public class RestartSoundLoopEventArgs : EventArgs 16 | { 17 | #region Properties 18 | 19 | public SoundSoundFile SoundSoundFile { get; set; } 20 | 21 | #endregion 22 | 23 | public RestartSoundLoopEventArgs(SoundSoundFile soundSoundFile) 24 | { 25 | SoundSoundFile = soundSoundFile; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Events/SoundFinishedEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: SoundFinishedEventArgs.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | using SoundCenSe.Configuration.Sounds; 12 | 13 | namespace SoundCenSe.Events 14 | { 15 | public class SoundFinishedEventArgs : EventArgs 16 | { 17 | #region Properties 18 | 19 | public Sound Sound { get; set; } 20 | public SoundFile SoundFile { get; set; } 21 | 22 | #endregion 23 | 24 | public SoundFinishedEventArgs(Sound sound, SoundFile soundFile) 25 | { 26 | Sound = sound; 27 | SoundFile = soundFile; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Events/SoundPlayingEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: SoundPlayingEventArgs.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | using SoundCenSe.Configuration.Sounds; 12 | 13 | namespace SoundCenSe.Events 14 | { 15 | public class SoundPlayingEventArgs : EventArgs 16 | { 17 | #region Properties 18 | 19 | public bool Mute { get; set; } 20 | 21 | public Sound Sound { get; set; } 22 | public SoundFile SoundFile { get; set; } 23 | public float Volume { get; set; } 24 | 25 | #endregion 26 | 27 | public SoundPlayingEventArgs(Sound sound, SoundFile soundFile, bool mute, float volume) 28 | { 29 | Sound = sound; 30 | SoundFile = soundFile; 31 | Mute = mute; 32 | Volume = volume; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Events/StartDownloadEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: StartDownloadEventArgs.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | using SoundCenSe.Utility.Updater; 12 | 13 | namespace SoundCenSe.Events 14 | { 15 | public class StartDownloadEventArgs : EventArgs 16 | { 17 | #region Properties 18 | 19 | public DownloadEntry File { get; set; } 20 | 21 | #endregion 22 | 23 | public StartDownloadEventArgs(DownloadEntry file) 24 | { 25 | File = file; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Events/UpdateFinishedEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: UpdateFinishedEventArgs.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | 12 | namespace SoundCenSe.Events 13 | { 14 | public class UpdateFinishedEventArgs : EventArgs 15 | { 16 | #region Properties 17 | 18 | public bool ReloadNecessary { get; set; } 19 | 20 | #endregion 21 | 22 | public UpdateFinishedEventArgs(bool reload) 23 | { 24 | ReloadNecessary = reload; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Events/XMLParseDoneEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: XMLParseDoneEventArgs.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | #region Usings 11 | 12 | using System; 13 | 14 | #endregion 15 | 16 | namespace SoundCenSe.Events 17 | { 18 | public class XMLParseDoneEventArgs : EventArgs 19 | { 20 | } 21 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Events/XMLParseProgressEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: XMLParseProgressEventArgs.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | 12 | namespace SoundCenSe.Events 13 | { 14 | public class XMLParseProgressEventArgs : EventArgs 15 | { 16 | #region Properties 17 | 18 | public string Filename { get; set; } 19 | 20 | #endregion 21 | 22 | public XMLParseProgressEventArgs(string filename) 23 | { 24 | Filename = filename; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/FmodSystem.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: FmodSystem.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | using System.Collections.Generic; 12 | using System.Windows.Forms; 13 | using FMOD; 14 | 15 | namespace SoundCenSe 16 | { 17 | public static class FmodSystem 18 | { 19 | #region Fields and Constants 20 | 21 | private static FMOD.System _system; 22 | 23 | public static Dictionary RawChannels = new Dictionary(); 24 | 25 | #endregion 26 | 27 | #region Properties 28 | 29 | public static FMOD.System System 30 | { 31 | get 32 | { 33 | if (_system == null) 34 | { 35 | Factory.System_Create(out _system); 36 | RESULT r = _system.init(32, INITFLAGS.NORMAL, IntPtr.Zero); 37 | if (r != RESULT.OK) 38 | { 39 | MessageBox.Show("Failed: " + r); 40 | } 41 | } 42 | return _system; 43 | } 44 | } 45 | 46 | #endregion 47 | 48 | public static void AddC(Channel c) 49 | { 50 | int id; 51 | c.getIndex(out id); 52 | if (RawChannels.ContainsKey(id)) 53 | { 54 | RawChannels[id] = c; 55 | } 56 | else 57 | { 58 | RawChannels.Add(id, c); 59 | } 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/GUI/SoundDisabler.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace SoundCenSe.GUI 2 | { 3 | partial class SoundDisabler 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | this.label1 = new System.Windows.Forms.Label(); 33 | this.btnDisable = new System.Windows.Forms.Button(); 34 | this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); 35 | this.SuspendLayout(); 36 | // 37 | // label1 38 | // 39 | this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 40 | | System.Windows.Forms.AnchorStyles.Right))); 41 | this.label1.AutoEllipsis = true; 42 | this.label1.Location = new System.Drawing.Point(32, 5); 43 | this.label1.Name = "label1"; 44 | this.label1.Size = new System.Drawing.Size(356, 17); 45 | this.label1.TabIndex = 0; 46 | this.label1.Text = "label1"; 47 | // 48 | // btnDisable 49 | // 50 | this.btnDisable.FlatAppearance.BorderSize = 0; 51 | this.btnDisable.Image = global::SoundCenSe.Properties.Resources.DisableSound_15x15; 52 | this.btnDisable.Location = new System.Drawing.Point(0, 0); 53 | this.btnDisable.Name = "btnDisable"; 54 | this.btnDisable.Size = new System.Drawing.Size(23, 23); 55 | this.btnDisable.TabIndex = 1; 56 | this.toolTip1.SetToolTip(this.btnDisable, "Disable sound"); 57 | this.btnDisable.UseVisualStyleBackColor = true; 58 | this.btnDisable.Click += new System.EventHandler(this.btnDisableClick); 59 | // 60 | // SoundDisabler 61 | // 62 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 63 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 64 | this.Controls.Add(this.btnDisable); 65 | this.Controls.Add(this.label1); 66 | this.Margin = new System.Windows.Forms.Padding(0); 67 | this.Name = "SoundDisabler"; 68 | this.Size = new System.Drawing.Size(388, 23); 69 | this.ResumeLayout(false); 70 | 71 | } 72 | 73 | #endregion 74 | 75 | private System.Windows.Forms.Label label1; 76 | private System.Windows.Forms.Button btnDisable; 77 | private System.Windows.Forms.ToolTip toolTip1; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/GUI/SoundDisabler.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: SoundDisabler.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | using System.IO; 12 | using System.Windows.Forms; 13 | using SoundCenSe.Events; 14 | 15 | namespace SoundCenSe.GUI 16 | { 17 | public partial class SoundDisabler : UserControl 18 | { 19 | #region Fields and Constants 20 | 21 | private string filename; 22 | public EventHandler SoundDisabled; 23 | 24 | #endregion 25 | 26 | #region Properties 27 | 28 | public string Filename 29 | { 30 | get { return filename; } 31 | set 32 | { 33 | filename = value; 34 | label1.Text = Path.GetFileNameWithoutExtension(filename); 35 | } 36 | } 37 | 38 | #endregion 39 | 40 | public SoundDisabler(string filename) 41 | { 42 | InitializeComponent(); 43 | Filename = filename; 44 | } 45 | 46 | public SoundDisabler() 47 | { 48 | InitializeComponent(); 49 | } 50 | 51 | private void btnDisableClick(object sender, EventArgs e) 52 | { 53 | var handler = SoundDisabled; 54 | if (handler != null) 55 | { 56 | handler(this, new DisableSoundEventArgs(filename, true)); 57 | } 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/GUI/SoundPanel.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace SoundCenSe.GUI 2 | { 3 | partial class SoundPanel 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.tablePanel = new System.Windows.Forms.TableLayoutPanel(); 32 | this.SuspendLayout(); 33 | // 34 | // tablePanel 35 | // 36 | this.tablePanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 37 | | System.Windows.Forms.AnchorStyles.Right))); 38 | this.tablePanel.AutoSize = true; 39 | this.tablePanel.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single; 40 | this.tablePanel.ColumnCount = 1; 41 | this.tablePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); 42 | this.tablePanel.Location = new System.Drawing.Point(0, 0); 43 | this.tablePanel.Name = "tablePanel"; 44 | this.tablePanel.RowCount = 1; 45 | this.tablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); 46 | this.tablePanel.Size = new System.Drawing.Size(284, 116); 47 | this.tablePanel.TabIndex = 0; 48 | // 49 | // SoundPanel 50 | // 51 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 52 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 53 | this.AutoScroll = true; 54 | this.Controls.Add(this.tablePanel); 55 | this.Name = "SoundPanel"; 56 | this.Size = new System.Drawing.Size(284, 362); 57 | this.ResumeLayout(false); 58 | this.PerformLayout(); 59 | 60 | } 61 | 62 | #endregion 63 | 64 | private System.Windows.Forms.TableLayoutPanel tablePanel; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/GUI/SoundPanel.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: SoundPanel.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | using System.Collections.Generic; 12 | using System.Linq; 13 | using System.Windows.Forms; 14 | using SoundCenSe.Configuration; 15 | using SoundCenSe.Events; 16 | using SoundCenSe.Utility; 17 | 18 | namespace SoundCenSe.GUI 19 | { 20 | public partial class SoundPanel : UserControl 21 | { 22 | #region Fields and Constants 23 | 24 | internal List channelSort = new List(); 25 | 26 | public EventHandler FastForward; 27 | public EventHandler Muting; 28 | public EventHandler SoundDisabled; 29 | public EventHandler VolumeChanged; 30 | 31 | #endregion 32 | 33 | public SoundPanel() 34 | { 35 | InitializeComponent(); 36 | } 37 | 38 | public void Clear() 39 | { 40 | tablePanel.Controls.Clear(); 41 | } 42 | 43 | private void FastForwardInternal(object sender, ChannelFastForwardEventArgs channelFastForwardEventArgs) 44 | { 45 | var handler = FastForward; 46 | if (handler != null) 47 | { 48 | handler(sender, channelFastForwardEventArgs); 49 | } 50 | } 51 | 52 | 53 | public void FillEntries(List channelNames) 54 | { 55 | int rowCount = 0; 56 | this.InvokeIfRequired(() => 57 | { 58 | foreach (string s in channelNames) 59 | { 60 | SoundPanelEntry spe = new SoundPanelEntry(); 61 | spe.ChannelName = s.Capitalize(); 62 | spe.Dock = DockStyle.Fill; 63 | // spe.Width = this.tablePanel.Width; 64 | if (s.ToLower() == "sfx") 65 | { 66 | spe.IsSFXPanel = true; 67 | } 68 | ChannelData cd = Config.Instance.Channels.FirstOrDefault(x => x.Channel == s.ToLower()); 69 | if (cd != null) 70 | { 71 | spe.VolumeBar.Value = (int) (cd.Volume*100); 72 | spe.btnMute.Checked = cd.Mute; 73 | } 74 | 75 | 76 | spe.FastForward += FastForwardInternal; 77 | spe.Muting += MutingInternal; 78 | spe.VolumeChanged += VolumeChangedInternal; 79 | spe.SoundDisabled += SoundDisabledInternal; 80 | spe.Anchor = AnchorStyles.Left | AnchorStyles.Right; 81 | 82 | tablePanel.Controls.Add(spe, 0, rowCount++); 83 | } 84 | }); 85 | } 86 | 87 | 88 | private void MutingInternal(object sender, ChannelMuteEventArgs channelMuteEventArgs) 89 | { 90 | var handler = Muting; 91 | if (handler != null) 92 | { 93 | handler(sender, channelMuteEventArgs); 94 | } 95 | } 96 | 97 | 98 | public void SetValues(string channel, string file, uint length, bool mute, float volume, bool looping) 99 | { 100 | SoundPanelEntry spe = 101 | tablePanel.Controls.OfType().FirstOrDefault(x => x.ChannelName == channel); 102 | if (spe == null) 103 | { 104 | throw new Exception("Channel not initialized yet? (" + channel + ")"); 105 | } 106 | spe.VolumeBar.Value = (int) (volume*100); 107 | spe.btnMute.Checked = mute; 108 | spe.btnFastForward.Visible = looping; 109 | if (spe.Filename != file) 110 | { 111 | spe.ChannelName = channel; 112 | spe.Filename = file; 113 | spe.Length = length; 114 | } 115 | spe.AddEntry(file); 116 | } 117 | 118 | private void SoundDisabledInternal(object sender, DisableSoundEventArgs disableSoundEventArgs) 119 | { 120 | var handler = SoundDisabled; 121 | if (handler != null) 122 | { 123 | handler(this, disableSoundEventArgs); 124 | } 125 | } 126 | 127 | public void Tick() 128 | { 129 | foreach (SoundPanelEntry s in tablePanel.Controls.OfType()) 130 | { 131 | s.Tick(); 132 | } 133 | } 134 | 135 | private void VolumeChangedInternal(object sender, ChannelVolumeEventArgs channelVolumeEventArgs) 136 | { 137 | var handler = VolumeChanged; 138 | if (handler != null) 139 | { 140 | handler(sender, channelVolumeEventArgs); 141 | } 142 | } 143 | } 144 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/GUI/SoundPanelEntry.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: SoundPanelEntry.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | using System.IO; 12 | using System.Windows.Forms; 13 | using SoundCenSe.Events; 14 | 15 | namespace SoundCenSe.GUI 16 | { 17 | public partial class SoundPanelEntry : UserControl 18 | { 19 | #region Fields and Constants 20 | 21 | private string channelName = ""; 22 | private DateTime endTime; 23 | 24 | public EventHandler FastForward; 25 | private string filename = ""; 26 | 27 | private bool isDown; 28 | private bool isSfxPanel; 29 | private uint length; 30 | public EventHandler Muting; 31 | 32 | public EventHandler SoundDisabled; 33 | public EventHandler VolumeChanged; 34 | 35 | #endregion 36 | 37 | #region Properties 38 | 39 | public string ChannelName 40 | { 41 | get { return channelName; } 42 | set 43 | { 44 | labelChannel.Text = value; 45 | channelName = value; 46 | } 47 | } 48 | 49 | public string Filename 50 | { 51 | get { return filename; } 52 | set 53 | { 54 | labelFile.Text = Path.GetFileNameWithoutExtension(value); 55 | filename = value; 56 | } 57 | } 58 | 59 | public bool IsSFXPanel 60 | { 61 | get { return isSfxPanel; } 62 | set 63 | { 64 | isSfxPanel = value; 65 | btnFastForward.Visible = !isSfxPanel; 66 | } 67 | } 68 | 69 | public uint Length 70 | { 71 | get { return length; } 72 | set 73 | { 74 | length = value; 75 | endTime = DateTime.UtcNow + TimeSpan.FromMilliseconds(length); 76 | labelLength.Text = (endTime - DateTime.UtcNow).ToString("g"); 77 | } 78 | } 79 | 80 | #endregion 81 | 82 | public SoundPanelEntry() 83 | { 84 | InitializeComponent(); 85 | } 86 | 87 | public void AddEntry(string filename) 88 | { 89 | if (!string.IsNullOrEmpty(filename.Trim())) 90 | { 91 | SoundDisabler sd = new SoundDisabler(filename); 92 | sd.Width = tablePanel.Width; 93 | sd.SoundDisabled += SoundDisabledInternal; 94 | sd.Anchor = AnchorStyles.Left | AnchorStyles.Right; 95 | AddInFront(sd); 96 | } 97 | } 98 | 99 | private void AddInFront(SoundDisabler sd) 100 | { 101 | tablePanel.RowStyles.Insert(0, new RowStyle(SizeType.AutoSize)); 102 | tablePanel.RowCount++; 103 | for (int i = tablePanel.Controls.Count - 1; i >= 0; i--) 104 | { 105 | tablePanel.SetRow(tablePanel.Controls[i], i + 1); 106 | } 107 | 108 | tablePanel.Controls.Add(sd, 0, 0); 109 | 110 | 111 | sd.BringToFront(); 112 | if (tablePanel.Controls.Count > 5) 113 | { 114 | foreach (Control control in tablePanel.Controls) 115 | { 116 | if (tablePanel.GetRow(control) >= 5) 117 | { 118 | tablePanel.Controls.Remove(control); 119 | control.Dispose(); 120 | } 121 | } 122 | tablePanel.RowCount--; 123 | } 124 | } 125 | 126 | private void button1_Click(object sender, EventArgs e) 127 | { 128 | this.SuspendLayout(); 129 | if (!isDown) 130 | { 131 | btnDwnUp.ImageIndex = 1; 132 | this.Height = 226; 133 | } 134 | else 135 | { 136 | btnDwnUp.ImageIndex = 0; 137 | this.Height = 121; 138 | } 139 | this.ResumeLayout(true); 140 | isDown = !isDown; 141 | } 142 | 143 | private void FastForwardClick(object sender, EventArgs e) 144 | { 145 | var handler = FastForward; 146 | if (handler != null) 147 | { 148 | handler(this, new ChannelFastForwardEventArgs(channelName)); 149 | } 150 | } 151 | 152 | private void MuteClick(object sender, EventArgs e) 153 | { 154 | var handler = Muting; 155 | if (handler != null) 156 | { 157 | handler(this, new ChannelMuteEventArgs(channelName, btnMute.Checked)); 158 | } 159 | } 160 | 161 | private void SoundDisabledInternal(object sender, DisableSoundEventArgs disableSoundEventArgs) 162 | { 163 | var handler = SoundDisabled; 164 | if (handler != null) 165 | { 166 | handler(this, disableSoundEventArgs); 167 | } 168 | } 169 | 170 | public void Tick() 171 | { 172 | if (endTime > DateTime.UtcNow) 173 | { 174 | labelLength.Text = (endTime - DateTime.UtcNow).ToString("mm\\:ss\\.f"); 175 | } 176 | else 177 | { 178 | labelLength.Text = ""; 179 | labelFile.Text = ""; 180 | } 181 | } 182 | 183 | private void VolumeBarValueChanged(object sender, EventArgs e) 184 | { 185 | var handler = VolumeChanged; 186 | if (handler != null) 187 | { 188 | handler(this, new ChannelVolumeEventArgs(channelName, VolumeBar.Value/100.0f)); 189 | } 190 | } 191 | } 192 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/GUI/ToolStripSignal.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: ToolStripSignal.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System.Drawing; 11 | using System.Windows.Forms; 12 | 13 | namespace SoundCenSe.GUI 14 | { 15 | public class ToolStripSignal : ToolStripStatusLabel 16 | { 17 | #region Fields and Constants 18 | 19 | private bool signal; 20 | 21 | #endregion 22 | 23 | #region Properties 24 | 25 | public bool Signal 26 | { 27 | get { return signal; } 28 | set 29 | { 30 | if (value != signal) 31 | { 32 | signal = value; 33 | this.Invalidate(); 34 | } 35 | } 36 | } 37 | 38 | #endregion 39 | 40 | protected override void OnPaint(PaintEventArgs e) 41 | { 42 | base.OnPaint(e); 43 | Color c = Color.Red; 44 | if (signal) 45 | { 46 | c = Color.Green; 47 | } 48 | using (Brush b = new SolidBrush(c)) 49 | { 50 | e.Graphics.FillEllipse(b, 2, 2, this.Height - 4, this.Height - 4); 51 | } 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Input/LogFileListener.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: LogFileListener.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | using System.IO; 12 | using System.Threading; 13 | using System.Threading.Tasks; 14 | using NLog; 15 | using SoundCenSe.Events; 16 | using SoundCenSe.Interfaces; 17 | 18 | namespace SoundCenSe.Input 19 | { 20 | public sealed class LogFileListener : IStoppable, IDisposable 21 | { 22 | #region Fields and Constants 23 | 24 | public static readonly Logger logger = LogManager.GetCurrentClassLogger(); 25 | public EventHandler GamelogEvent; 26 | private TextReader logfileReader; 27 | private FileStream logFileStream; 28 | private bool stop; 29 | 30 | #endregion 31 | 32 | public LogFileListener(string filename, bool beginAtEnd = false) 33 | { 34 | logFileStream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); 35 | logfileReader = new StreamReader(logFileStream); 36 | if (beginAtEnd) 37 | { 38 | BeginAtEnd(); 39 | } 40 | } 41 | 42 | #region IDisposable Members 43 | 44 | public void Dispose() 45 | { 46 | Dispose(true); 47 | GC.SuppressFinalize(this); 48 | } 49 | 50 | #endregion 51 | 52 | #region IStoppable Members 53 | 54 | public void Start() 55 | { 56 | Task.Factory.StartNew(() => DoWork()); 57 | } 58 | 59 | public void Stop() 60 | { 61 | stop = true; 62 | } 63 | 64 | #endregion 65 | 66 | public void BeginAtEnd() 67 | { 68 | logfileReader.ReadToEnd(); 69 | } 70 | 71 | private void Dispose(bool disposing) 72 | { 73 | if (disposing) 74 | { 75 | Stop(); 76 | logfileReader.Dispose(); 77 | logFileStream.Dispose(); 78 | logfileReader = null; 79 | logFileStream = null; 80 | } 81 | } 82 | 83 | private void DoWork() 84 | { 85 | stop = false; 86 | while (!stop) 87 | { 88 | if (logfileReader == null) 89 | { 90 | break; 91 | } 92 | string line = logfileReader.ReadLine(); 93 | if (line != null) 94 | { 95 | OnLogfileEvent(line); 96 | continue; 97 | } 98 | 99 | Thread.Sleep(50); 100 | } 101 | } 102 | 103 | private void OnLogfileEvent(string line) 104 | { 105 | var handler = GamelogEvent; 106 | if (handler != null) 107 | { 108 | handler(this, new GamelogEventArgs(line)); 109 | } 110 | } 111 | } 112 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Interfaces/IPlayerManager.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: IPlayerManager.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using SoundCenSe.Configuration.Sounds; 11 | using SoundCenSe.Enums; 12 | 13 | namespace SoundCenSe.Interfaces 14 | { 15 | public interface IPlayerManager 16 | { 17 | #region Properties 18 | 19 | Threshold Threshold { get; set; } 20 | float Volume { get; set; } 21 | 22 | #endregion 23 | 24 | void Play(Sound sound, long x, long y, long z); 25 | } 26 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Interfaces/IStoppable.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: IStoppable.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | namespace SoundCenSe.Interfaces 11 | { 12 | public interface IStoppable 13 | { 14 | void Start(); 15 | void Stop(); 16 | } 17 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/NLog.config: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 13 | 14 | 15 | 19 | 20 | 21 | 26 | 27 | 28 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 43 | 44 | -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Output/DummyPlayerManager.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: DummyPlayerManager.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System.Collections.Generic; 11 | using SoundCenSe.Configuration.Sounds; 12 | using SoundCenSe.Enums; 13 | using SoundCenSe.Interfaces; 14 | 15 | namespace SoundCenSe.Output 16 | { 17 | public class DummyPlayerManager : IPlayerManager 18 | { 19 | #region Fields and Constants 20 | 21 | public readonly Dictionary Channels = new Dictionary(); 22 | 23 | #endregion 24 | 25 | #region IPlayerManager Members 26 | 27 | public Threshold Threshold { get; set; } 28 | public float Volume { get; set; } 29 | 30 | public void Play(Sound sound, long x, long y, long z) 31 | { 32 | if (sound.PlaybackThreshold <= (long) Config.Instance.playbackThreshold) 33 | { 34 | if (!string.IsNullOrEmpty(sound.Channel)) 35 | { 36 | if (!Channels.ContainsKey(sound.Channel)) 37 | { 38 | Channels.Add(sound.Channel, sound); 39 | } 40 | else 41 | { 42 | Channels[sound.Channel] = sound; 43 | } 44 | } 45 | } 46 | } 47 | 48 | #endregion 49 | } 50 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Output/DummySoundProcessor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: DummySoundProcessor.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System.Linq; 11 | using System.Text.RegularExpressions; 12 | using SoundCenSe.Configuration.Sounds; 13 | using SoundCenSe.Events; 14 | 15 | namespace SoundCenSe.Output 16 | { 17 | public class DummySoundProcessor : SoundProcessor 18 | { 19 | #region Properties 20 | 21 | public DummyPlayerManager DummyPlayerManager { get; set; } 22 | 23 | #endregion 24 | 25 | public DummySoundProcessor(SoundsXML sounds) : base(sounds) 26 | { 27 | this.soundsXML.Sounds = sounds.Sounds.Where(x => !string.IsNullOrEmpty(x.Channel)).ToList(); 28 | } 29 | 30 | public override void ProcessLine(object sender, GamelogEventArgs e) 31 | { 32 | string line = e.Line; 33 | 34 | int matches = 0; 35 | Sound matchedSound = null; 36 | 37 | if (this.repeater.IsMatch(line)) 38 | { 39 | if (this.lastSFX != null) 40 | { 41 | DummyPlayerManager.Play(this.lastSFX, 0, 0, 0); 42 | } 43 | return; 44 | } 45 | Match matcher = this.coordinatePattern.Match(line); 46 | 47 | long x = long.MinValue; 48 | long y = long.MinValue; 49 | long z = long.MinValue; 50 | if (matcher.Success) 51 | { 52 | x = long.Parse(matcher.Groups[1].Value); 53 | y = long.Parse(matcher.Groups[2].Value); 54 | z = long.Parse(matcher.Groups[3].Value); 55 | line = matcher.Groups[4].Value; 56 | } 57 | 58 | foreach (Sound sound in this.soundsXML.Sounds) 59 | { 60 | if (!Config.Instance.disabledSounds.Contains(sound.ParentFile) && 61 | (sound.Matches(line))) 62 | { 63 | matches++; 64 | matchedSound = sound; 65 | 66 | DummyPlayerManager.Play(sound, x, y, z); 67 | 68 | if (string.IsNullOrEmpty(sound.Channel)) 69 | { 70 | this.lastSFX = sound; 71 | } 72 | 73 | if (sound.HaltOnMatch) 74 | { 75 | break; 76 | } 77 | } 78 | } 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Output/SoundProcessor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: SoundProcessor.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System.Text; 11 | using System.Text.RegularExpressions; 12 | using NLog; 13 | using SoundCenSe.Configuration.Sounds; 14 | using SoundCenSe.Events; 15 | using SoundCenSe.fmodInternal; 16 | 17 | namespace SoundCenSe.Output 18 | { 19 | public class SoundProcessor 20 | { 21 | #region Fields and Constants 22 | 23 | private static readonly Logger logger = LogManager.GetCurrentClassLogger(); 24 | private static readonly Logger missingLogger = LogManager.GetLogger("missing"); 25 | internal readonly Regex coordinatePattern; 26 | 27 | internal Sound lastSFX; 28 | 29 | internal readonly Regex repeater = new Regex("^x\\d{1,3}$"); 30 | internal readonly SoundsXML soundsXML; 31 | 32 | #endregion 33 | 34 | public SoundProcessor(SoundsXML sounds) 35 | { 36 | soundsXML = sounds; 37 | coordinatePattern = new Regex("\\[(\\-?\\d),(\\-?\\d),(\\-?\\d)\\] (.*)"); 38 | } 39 | 40 | public virtual void ProcessLine(object sender, GamelogEventArgs e) 41 | { 42 | string line = e.Line; 43 | 44 | int matches = 0; 45 | Sound matchedSound = null; 46 | 47 | if (repeater.IsMatch(line)) 48 | { 49 | if (lastSFX != null) 50 | { 51 | fmodPlayer.Instance.Play(lastSFX, 0, 0, 0); 52 | } 53 | return; 54 | } 55 | Match matcher = coordinatePattern.Match(line); 56 | 57 | long x = long.MinValue; 58 | long y = long.MinValue; 59 | long z = long.MinValue; 60 | if (matcher.Success) 61 | { 62 | x = long.Parse(matcher.Groups[1].Value); 63 | y = long.Parse(matcher.Groups[2].Value); 64 | z = long.Parse(matcher.Groups[3].Value); 65 | line = matcher.Groups[4].Value; 66 | } 67 | 68 | foreach (Sound sound in soundsXML.Sounds) 69 | { 70 | if (!Config.Instance.disabledSounds.Contains(sound.ParentFile) && 71 | (sound.Matches(line))) 72 | { 73 | matches++; 74 | matchedSound = sound; 75 | logger.Info("Message '" + line + "' matched event '" + sound + "' from '" + sound.ParentFile + "'."); 76 | 77 | fmodPlayer.Instance.Play(sound, x, y, z); 78 | 79 | if (string.IsNullOrEmpty(sound.Channel)) 80 | { 81 | lastSFX = sound; 82 | } 83 | 84 | if (sound.HaltOnMatch) 85 | { 86 | logger.Info("Ending Match prematurely as expected."); 87 | break; 88 | } 89 | logger.Info("Continuing for next rule match."); 90 | } 91 | } 92 | 93 | if (matchedSound == null) 94 | { 95 | logger.Info(line); 96 | logger.Info("Message '" + line + "' did not match any rule."); 97 | missingLogger.Warn(line); 98 | } 99 | else 100 | { 101 | StringBuilder sb = new StringBuilder(); 102 | if (matchedSound.AnsiFormat != null) 103 | { 104 | sb.Append(matchedSound.AnsiFormat); 105 | sb.Append(line); 106 | 107 | logger.Info(sb.ToString()); 108 | logger.Info("Message '" + line + "' matched " + matches + " rules."); 109 | } 110 | } 111 | } 112 | } 113 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Program.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: Program.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | using System.Windows.Forms; 12 | 13 | namespace SoundCenSe 14 | { 15 | static class Program 16 | { 17 | /// 18 | /// The main entry point for the application. 19 | /// 20 | [STAThread] 21 | static void Main() 22 | { 23 | Application.EnableVisualStyles(); 24 | Application.SetCompatibleTextRenderingDefault(false); 25 | Application.Run(new SoundCenSeForm()); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Program.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe WinForms/SoundCenSe/Program.ico -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: AssemblyInfo.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System.Reflection; 11 | using System.Runtime.InteropServices; 12 | 13 | // General Information about an assembly is controlled through the following 14 | // set of attributes. Change these attribute values to modify the information 15 | // associated with an assembly. 16 | 17 | [assembly: AssemblyTitle("SoundCenSe")] 18 | [assembly: AssemblyDescription("")] 19 | [assembly: AssemblyConfiguration("")] 20 | [assembly: AssemblyCompany("")] 21 | [assembly: AssemblyProduct("SoundCenSe")] 22 | [assembly: AssemblyCopyright("None")] 23 | [assembly: AssemblyTrademark("")] 24 | [assembly: AssemblyCulture("")] 25 | 26 | // Setting ComVisible to false makes the types in this assembly not visible 27 | // to COM components. If you need to access a type in this assembly from 28 | // COM, set the ComVisible attribute to true on that type. 29 | 30 | [assembly: ComVisible(false)] 31 | 32 | // The following GUID is for the ID of the typelib if this project is exposed to COM 33 | 34 | [assembly: Guid("2c19650d-0695-4619-9913-fa1839d2fe08")] 35 | 36 | // Version information for an assembly consists of the following four values: 37 | // 38 | // Major Version 39 | // Minor Version 40 | // Build Number 41 | // Revision 42 | // 43 | // You can specify all the values or you can default the Build and Revision Numbers 44 | // by using the '*' as shown below: 45 | // [assembly: AssemblyVersion("1.0.*")] 46 | 47 | [assembly: AssemblyVersion("1.2.4.0")] 48 | [assembly: AssemblyFileVersion("1.2.4.0")] -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SoundCenSe.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SoundCenSe.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Drawing.Bitmap. 65 | /// 66 | internal static System.Drawing.Bitmap ArrowDown { 67 | get { 68 | object obj = ResourceManager.GetObject("ArrowDown", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// Looks up a localized resource of type System.Drawing.Bitmap. 75 | /// 76 | internal static System.Drawing.Bitmap ArrowUp { 77 | get { 78 | object obj = ResourceManager.GetObject("ArrowUp", resourceCulture); 79 | return ((System.Drawing.Bitmap)(obj)); 80 | } 81 | } 82 | 83 | /// 84 | /// Looks up a localized resource of type System.Drawing.Bitmap. 85 | /// 86 | internal static System.Drawing.Bitmap DisableSound_15x15 { 87 | get { 88 | object obj = ResourceManager.GetObject("DisableSound_15x15", resourceCulture); 89 | return ((System.Drawing.Bitmap)(obj)); 90 | } 91 | } 92 | 93 | /// 94 | /// Looks up a localized resource of type System.Drawing.Bitmap. 95 | /// 96 | internal static System.Drawing.Bitmap FastForward { 97 | get { 98 | object obj = ResourceManager.GetObject("FastForward", resourceCulture); 99 | return ((System.Drawing.Bitmap)(obj)); 100 | } 101 | } 102 | 103 | /// 104 | /// Looks up a localized resource of type System.Drawing.Bitmap. 105 | /// 106 | internal static System.Drawing.Bitmap Mute { 107 | get { 108 | object obj = ResourceManager.GetObject("Mute", resourceCulture); 109 | return ((System.Drawing.Bitmap)(obj)); 110 | } 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SoundCenSe.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Resources/ArrowDown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe WinForms/SoundCenSe/Resources/ArrowDown.png -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Resources/ArrowUp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe WinForms/SoundCenSe/Resources/ArrowUp.png -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Resources/DisableSound 15x15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe WinForms/SoundCenSe/Resources/DisableSound 15x15.png -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Resources/FastForward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe WinForms/SoundCenSe/Resources/FastForward.png -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Resources/FastForwardImg.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe WinForms/SoundCenSe/Resources/FastForwardImg.bmp -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Resources/Mute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe WinForms/SoundCenSe/Resources/Mute.png -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Utility/ISynchronizeInvokeExtension.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: ISynchronizeInvokeExtension.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System.ComponentModel; 11 | using System.Windows.Forms; 12 | 13 | namespace SoundCenSe.Utility 14 | { 15 | public static class ISynchronizeInvokeExtension 16 | { 17 | public static void InvokeIfRequired(this ISynchronizeInvoke obj, 18 | MethodInvoker action) 19 | { 20 | if (obj.InvokeRequired) 21 | { 22 | var args = new object[0]; 23 | obj.Invoke(action, args); 24 | } 25 | else 26 | { 27 | action(); 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Utility/SFXQueue.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: SFXQueue.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System; 11 | using System.Collections.Generic; 12 | using SoundCenSe.Configuration.Sounds; 13 | 14 | namespace SoundCenSe.Utility 15 | { 16 | public static class SFXQueue 17 | { 18 | #region Fields and Constants 19 | 20 | private static readonly Queue> soundQueue = 21 | new Queue>(); 22 | 23 | #endregion 24 | 25 | #region Properties 26 | 27 | public static int Count 28 | { 29 | get 30 | { 31 | lock (soundQueue) 32 | { 33 | return soundQueue.Count; 34 | } 35 | } 36 | } 37 | 38 | #endregion 39 | 40 | public static void AddSound(Sound s, long x, long y, long z) 41 | { 42 | lock (soundQueue) 43 | { 44 | soundQueue.Enqueue(new Tuple(x, y, z, s)); 45 | } 46 | } 47 | 48 | public static Tuple GetSound() 49 | { 50 | lock (soundQueue) 51 | { 52 | if (soundQueue.Count == 0) 53 | { 54 | return null; 55 | } 56 | return soundQueue.Dequeue(); 57 | } 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Utility/StringExtension.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: StringExtension.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | namespace SoundCenSe.Utility 11 | { 12 | public static class StringExtension 13 | { 14 | public static string Capitalize(this string s) 15 | { 16 | // Check for empty string. 17 | if (string.IsNullOrEmpty(s)) 18 | { 19 | return string.Empty; 20 | } 21 | // Return char and concat substring. 22 | return char.ToUpper(s[0]) + s.Substring(1); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Utility/Updater/DownloadEntry.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: DownloadEntry.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | #region Usings 11 | 12 | using System; 13 | using System.IO; 14 | using System.Net; 15 | using SoundCenSe.Events; 16 | 17 | #endregion 18 | 19 | namespace SoundCenSe.Utility.Updater 20 | { 21 | public class DownloadEntry : IDisposable 22 | { 23 | #region Fields and Constants 24 | 25 | public EventHandler FinishedFile; 26 | 27 | #endregion 28 | 29 | #region Properties 30 | 31 | public string DestinationPath { get; set; } 32 | public string ExpectedSHA { get; set; } 33 | public long ExpectedSize { get; set; } 34 | public DownloadResult Result { get; set; } 35 | 36 | public string SourceURL { get; set; } 37 | public HttpStatusCode StatusCode { get; set; } 38 | public string TempFileName { get; set; } 39 | 40 | #endregion 41 | 42 | #region IDisposable Members 43 | 44 | public void Dispose() 45 | { 46 | Dispose(true); 47 | GC.SuppressFinalize(this); 48 | } 49 | 50 | #endregion 51 | 52 | private void Dispose(bool disposing) 53 | { 54 | if (disposing) 55 | { 56 | if (File.Exists(TempFileName)) 57 | { 58 | File.Delete(TempFileName); 59 | } 60 | } 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Utility/Updater/DownloadResult.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: DownloadResult.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | namespace SoundCenSe.Utility.Updater 11 | { 12 | public enum DownloadResult 13 | { 14 | OK, 15 | Error404, 16 | ErrorSHA, 17 | ErrorSize 18 | } 19 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Utility/Updater/XML/DirectoryData.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: DirectoryData.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | namespace SoundCenSe.Utility.Updater.XML 11 | { 12 | public class DirectoryData 13 | { 14 | #region Properties 15 | 16 | public string Filename { get; set; } 17 | 18 | public string RelativePath { get; set; } 19 | public string SHA1 { get; set; } 20 | public long Size { get; set; } 21 | 22 | #endregion 23 | } 24 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/Utility/Updater/XML/UpdateParser.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: UpdateParser.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | #region Usings 11 | 12 | using System; 13 | using System.Collections.Generic; 14 | using System.IO; 15 | using System.Security.Cryptography; 16 | using System.Xml; 17 | using SoundCenSe.Configuration; 18 | 19 | #endregion 20 | 21 | namespace SoundCenSe.Utility.Updater.XML 22 | { 23 | public class UpdateParser 24 | { 25 | public static List Parse(string filename) 26 | { 27 | XmlDocument doc = new XmlDocument(); 28 | TextReader tr = new StreamReader(filename); 29 | string xmldata = tr.ReadToEnd().Replace(" data = new List(); 34 | 35 | XmlNodeList nl = doc.GetElementsByTagName("autoUpdater"); 36 | XmlNode main = nl.Item(0); 37 | string relpath = ""; 38 | 39 | foreach (XmlNode dirnode in main.ChildNodes) 40 | { 41 | ParseDir(dirnode, data, relpath); 42 | } 43 | return data; 44 | } 45 | 46 | private static void ParseDir(XmlNode dirnode, List data, string relpath) 47 | { 48 | bool ignore = dirnode.ParseBoolAttribute("ignore", false); 49 | if (!ignore) 50 | { 51 | if (dirnode.LocalName == "directory") 52 | { 53 | // Recursive into subfolders 54 | string dName = dirnode.Attributes.GetNamedItem("name").Value; 55 | string relpathNew = Path.Combine(relpath, dName); 56 | foreach (XmlNode newNode in dirnode.ChildNodes) 57 | { 58 | ParseDir(newNode, data, relpathNew); 59 | } 60 | } 61 | else if (dirnode.LocalName == "file") 62 | { 63 | // Generate File data 64 | DirectoryData dd = new DirectoryData(); 65 | dd.Filename = dirnode.Attributes.GetNamedItem("name").Value; 66 | dd.RelativePath = relpath; 67 | dd.Size = dirnode.ParseLongAttribute("size", -1); 68 | dd.SHA1 = dirnode.Attributes.GetNamedItem("sha1").Value.ToLower(); 69 | data.Add(dd); 70 | } 71 | } 72 | } 73 | 74 | public static string SHA1Checksum(string filename) 75 | { 76 | string check = ""; 77 | if (!File.Exists(filename)) 78 | { 79 | return ""; 80 | } 81 | try 82 | { 83 | using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) 84 | { 85 | using (SHA1CryptoServiceProvider crypto = new SHA1CryptoServiceProvider()) 86 | { 87 | check = BitConverter.ToString(crypto.ComputeHash(fs)).Replace("-", "").ToLower(); 88 | } 89 | } 90 | } 91 | catch (Exception) 92 | { 93 | } 94 | 95 | return check; 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/fmod.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe WinForms/SoundCenSe/fmod.dll -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/fmodInternal/SoundSoundFile.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: SoundSoundFile.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using SoundCenSe.Configuration.Sounds; 11 | 12 | namespace SoundCenSe.fmodInternal 13 | { 14 | public class SoundSoundFile 15 | { 16 | #region Properties 17 | 18 | public FMOD.Sound fmodSound { get; set; } 19 | public Sound Sound { get; set; } 20 | public SoundFile SoundFile { get; set; } 21 | 22 | #endregion 23 | 24 | public SoundSoundFile(Sound sound, SoundFile soundFile) 25 | { 26 | Sound = sound; 27 | SoundFile = soundFile; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/fmodInternal/fmodChannelPool.cs: -------------------------------------------------------------------------------- 1 | // 2 | // SoundSense C# Port aka SoundCenSe 3 | // 4 | // Solution: SoundCenSe 5 | // Project: SoundCenSe 6 | // File: fmodChannelPool.cs 7 | // 8 | // Last modified: 2016-07-30 19:37 9 | 10 | using System.Collections.Generic; 11 | using System.Linq; 12 | 13 | namespace SoundCenSe.fmodInternal 14 | { 15 | public class FmodChannelPool 16 | { 17 | #region Fields and Constants 18 | 19 | private static FmodChannelPool instance; 20 | 21 | private readonly Dictionary, fmodChannelSound> channels = 22 | new Dictionary, fmodChannelSound>(); 23 | 24 | #endregion 25 | 26 | #region Properties 27 | 28 | public static FmodChannelPool Instance 29 | { 30 | get 31 | { 32 | if (instance == null) 33 | { 34 | instance = new FmodChannelPool(); 35 | } 36 | return instance; 37 | } 38 | } 39 | 40 | #endregion 41 | 42 | public IEnumerable AllChannels() 43 | { 44 | return channels.Select(x => x.Value); 45 | } 46 | 47 | public int ConcurrentSounds(string channelname) 48 | { 49 | lock (channels) 50 | { 51 | return channels.Count(x => x.Key.Value == channelname); 52 | } 53 | } 54 | 55 | public fmodChannelSound GetSingleChannel(string channel) 56 | { 57 | lock (channels) 58 | { 59 | return channels.Single(x => x.Key.Value == channel.ToLower()).Value; 60 | } 61 | } 62 | 63 | public void RegisterChannel(fmodChannelSound channel) 64 | { 65 | lock (channels) 66 | { 67 | if (channel.ChannelName.ToLower() != "sfx") 68 | { 69 | if (channels.Count(x => x.Key.Value == channel.ChannelName.ToLower()) > 0) 70 | { 71 | return; 72 | } 73 | } 74 | KeyValuePair kv = new KeyValuePair(channel.Id, channel.ChannelName); 75 | channels.Add(kv, channel); 76 | } 77 | } 78 | 79 | public void StopAll() 80 | { 81 | fmodChannelSound[] list; 82 | lock (channels) 83 | { 84 | list = channels.Select(x => x.Value).ToArray(); 85 | } 86 | foreach (var c in list) 87 | { 88 | c.Dispose(); 89 | } 90 | } 91 | 92 | 93 | public void UnregisterChannel(fmodChannelSound channel) 94 | { 95 | lock (channels) 96 | { 97 | KeyValuePair kv = new KeyValuePair(channel.Id, channel.ChannelName); 98 | channels.Remove(kv); 99 | } 100 | } 101 | 102 | public bool IsSoundPlaying(string filename) 103 | { 104 | foreach (var sf in channels.Values) 105 | { 106 | if (sf.SoundSoundFile.SoundFile.Filename == filename) 107 | { 108 | return true; 109 | } 110 | } 111 | return false; 112 | } 113 | } 114 | } -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/fmodstudio.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/SoundCenSe WinForms/SoundCenSe/fmodstudio.dll -------------------------------------------------------------------------------- /SoundCenSe WinForms/SoundCenSe/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /fmod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Algorithman/SoundCenSe/8e31ac2140f045fd881692ee670a1e5574ac05d1/fmod.png --------------------------------------------------------------------------------