commit 4135b11764eebbf670df78a44dae7de90829ee77 Author: Umiko Date: Sun May 4 11:23:13 2025 +0700 Initial commit. diff --git a/CONTRIBUTER.md b/CONTRIBUTER.md new file mode 100644 index 0000000..8024693 --- /dev/null +++ b/CONTRIBUTER.md @@ -0,0 +1,22 @@ +# Contributors + +Thanks to the following people who have contributed to this project: + +| Name | Contribution | +| ------------- | ----------------------------- | +| Rafli (OWNER) | Initial development, design | + + +--- + +## How to Contribute + +We welcome contributions from everyone! +If you want to contribute: +1. Make sure you are signed in [here](https://git.techlabs.lol/user/login). +2. Fork the repository. +3. Create a new branch. +4. Make your changes. +5. Submit a pull request. + +Thanks for helping to make this project better! diff --git a/MIT-LICENSE.txt b/MIT-LICENSE.txt new file mode 100644 index 0000000..173554d --- /dev/null +++ b/MIT-LICENSE.txt @@ -0,0 +1,12 @@ +The MIT License +Version N/A +SPDX short identifier: MIT +Open Source Initiative Approved License + +Copyright 2025 Radiant Code + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..34372a2 --- /dev/null +++ b/README.md @@ -0,0 +1,96 @@ +# SoundBoard.AHK + +A lightweight, fully customizable soundboard built with AutoHotkey. +Allows users to assign sound files to hotkeys dynamically through an `.ini` configuration file. No recompiling needed to change keys or sounds since it's handled on the seperate file. + +--- + +## Features +- **Custom Hotkeys**: Bind any key you want with control (`Ctrl`) or alt (`Alt`) modifiers (by default). +- **Fully Configurable**: All key and modifier settings are stored in a simple `.ini` file. +- **Save and Reload Settings**: Save hotkey and sound assignments anytime without restarting the script. +- **Minimal & Fast**: No external libraries required, fully standalone. + +--- + +## How It Works + +1. All hotkey mappings are loaded from a `.ini` file (`save.ini` by default). +2. Modifier keys (e.g., Control, Alt) can also be customized through the ini. +3. Two types of actions: + - **Browse**: Press `Control + [Your Key]` to select a sound file (BY DEFAULT). + - **Play**: Press `Alt + [Your Key]` to play the assigned sound (BY DEFAULT). + +The script automatically handles key registration at runtime. + +--- + +## Default Controls + +| Action | Key Combination | Description | +|--------------|-------------------------|--------------------------| +| Browse Sound | `Ctrl + [Assigned Key]` | Choose a sound file | +| Play Sound | `Alt + [Assigned Key]` | Play assigned sound | +| Save Mapping | `Ctrl + Alt + Shift +s` | Save all key mappings | +| Exit Script | `Ctrl + Win + Alt + X` | Exit the soundboard | + +All keys are configurable via `save.ini`. + +--- + +## Example `save.ini` + +```ini +[Settings] +ControllerModifier=^ +SoundModifier=! + +[GeneralHotkeys] +SaveKey=^!+s +ExitKey=^#!x + +[h1] +key=F1 +path=C:\Sounds\sound1.wav + +[h2] +key=F2 +path=C:\Sounds\sound2.wav + +; Add more sections like [h3], [h4], etc. +```` + +--- + +## How To Use + +1. Install [AutoHotkey v1.1](https://www.autohotkey.com/) (classic) if you don't have it. +2. Clone this repository or download the `.ahk` script. +3. Edit `save.ini` according to your preferred hotkeys and sound files. +4. Run the script (`soundboard.ahk`). +5. Enjoy your custom soundboard! + +--- + +## ⚙Requirements + +* Windows OS +* AutoHotkey v1.1 (or newer) + +--- + +## License + +This project is licensed under the [MIT License](MIT-LICENSE.txt). + +## Support This Project + +If you find this project helpful, you can support my work by donating via PayPal: +👉 [![Donate](https://img.shields.io/badge/Donate-PayPal-blue.svg)](https://www.paypal.me/rafli23115) + +Thank you for your support! + +--- + +> Crafted with 💡 and code by **TechLabs.** +**Leaping over limits, one project at a time. ♾** diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..7c4eb7a --- /dev/null +++ b/changelog.md @@ -0,0 +1,33 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [0.1.0] - 2025-05-04 +### Added +- Ability to load settings from `save.ini`. +- Support for customizable Save, Exit, and Reload hotkeys. +- Dynamic loading of hotkeys for browsing and playing sound files. +- Dispatcher system to handle multiple types of hotkey actions. +- Save function to persist current keys and paths into `save.ini`. +- Reload function to update hotkeys without restarting the application. +- Basic file browser dialog to assign new sound files. +- Sound player to play assigned sound files. +- Global initialization for keys, paths, and hotkey mappings. +- New modifiers: Ctrl for browsing sounds and Alt for playing sounds, both configurable through the INI file. + +### Changed +- Refactored the entire codebase so that keys are no longer hardcoded. + +### Deprecated +- None. + +### Removed +- Removed all hardcoded keys like Numpad1, Numpad2 up to Numpad9. + +### Fixed +- None. +``` \ No newline at end of file diff --git a/save.ini b/save.ini new file mode 100644 index 0000000..a4fbd60 --- /dev/null +++ b/save.ini @@ -0,0 +1,23 @@ +[Settings] +ControllerModifier=^ + ; For browsing file, (Default control). +SoundModifier=! + ; For playing sound (default alt). + +[GeneralHotkeys] +SaveKey=^!+s +ExitKey=^#!x +ReloadKey=^!+r + + ; Begin the soun dscript. +[h1] +key=F1 +path=C:\Sounds\sound1.wav + +[h2] +key=F2 +path=C:\Sounds\sound2.wav + +[h3] +key=F3 +path=C:\Sounds\sound3.wav diff --git a/soundBoard$.exe b/soundBoard$.exe new file mode 100644 index 0000000..606b043 Binary files /dev/null and b/soundBoard$.exe differ diff --git a/soundBoard.ahk b/soundBoard.ahk new file mode 100644 index 0000000..b44b55e --- /dev/null +++ b/soundBoard.ahk @@ -0,0 +1,141 @@ +iniFile := "save.ini" + +; --- Load settings --- +IniRead, controllerModifier, %iniFile%, Settings, ControllerModifier, ^ +IniRead, soundModifier, %iniFile%, Settings, SoundModifier, ! + +IniRead, SaveKey, %iniFile%, GeneralHotkeys, SaveKey, ^Numpad0 +IniRead, ExitKey, %iniFile%, GeneralHotkeys, ExitKey, ^#Numpad0 +IniRead, ReloadKey, %iniFile%, GeneralHotkeys, ReloadKey, ^Numpad1 ; <- Tambah ini! + +; --- Initialize globals --- +global Keys := [] +global Paths := [] +global HotkeyMap := {} + +LoadHotkeys() + +; --- Bind SaveKey, ExitKey, and ReloadKey --- +Hotkey, %SaveKey%, SaveData +Hotkey, %ExitKey%, ExitAppHandler +Hotkey, %ReloadKey%, ReloadData ; <- Bind reload! + +return + +; --- Load all hotkeys from INI --- +LoadHotkeys() +{ + global Keys, Paths, HotkeyMap, iniFile, controllerModifier, soundModifier + + ; Clear previous keys + Keys := [] + Paths := [] + HotkeyMap := {} + + idx := 1 + Loop + { + section := "h" idx + IniRead, key, %iniFile%, %section%, key, ERROR + IniRead, path, %iniFile%, %section%, path, ERROR + + if (key = "ERROR") + break + + Keys.Push(key) + Paths.Push(path) + + browseHotkey := controllerModifier . key + playHotkey := soundModifier . key + + HotkeyMap[browseHotkey] := ["Browse", idx] + HotkeyMap[playHotkey] := ["Play", idx] + + Hotkey, %browseHotkey%, HotkeyDispatcher + Hotkey, %playHotkey%, HotkeyDispatcher + + idx++ + } +} + +; --- Dispatcher for all hotkeys --- +HotkeyDispatcher: +thisHotkey := A_ThisHotkey +actionInfo := HotkeyMap[thisHotkey] +if (!actionInfo) + return + +action := actionInfo[1] +idx := actionInfo[2] + +if (action = "Browse") + BrowseFile(idx) +else if (action = "Play") + PlaySound(idx) +return + +; --- Save current keys and paths --- +SaveData: +IniWrite, %controllerModifier%, %iniFile%, Settings, ControllerModifier +IniWrite, %soundModifier%, %iniFile%, Settings, SoundModifier +IniWrite, %SaveKey%, %iniFile%, GeneralHotkeys, SaveKey +IniWrite, %ExitKey%, %iniFile%, GeneralHotkeys, ExitKey +IniWrite, %ReloadKey%, %iniFile%, GeneralHotkeys, ReloadKey + +Loop % Keys.Length() +{ + section := "h" A_Index + IniWrite, % Keys[A_Index], %iniFile%, %section%, key + IniWrite, % Paths[A_Index], %iniFile%, %section%, path +} +MsgBox, Saved! +return + +; --- Reload keys and hotkeys from INI --- +ReloadData: +; First unbind all old hotkeys +for hkName, _ in HotkeyMap + Hotkey, %hkName%, Off + +; Reload modifiers and keys again +IniRead, controllerModifier, %iniFile%, Settings, ControllerModifier, ^ +IniRead, soundModifier, %iniFile%, Settings, SoundModifier, ! + +LoadHotkeys() +MsgBox, Reloaded hotkeys from INI! +return + +; --- Exit application --- +ExitAppHandler: +MsgBox, Exiting... +ExitApp +return + +; --- Browse a file and assign it --- +BrowseFile(idx) +{ + global Keys, Paths + FileSelectFile, SelectedFile, 1, , Select a sound, Audio Files (*.wav; *.mp3) + if (!SelectedFile) + return + Paths[idx] := SelectedFile +} + +; --- Play a sound file --- +PlaySound(idx) +{ + global Paths + FilePath := Paths[idx] + if (FilePath = "") + { + MsgBox, No file selected. + } + else if !FileExist(FilePath) + { + MsgBox, File does not exist. + } + else + { + SoundPlay, %FilePath% + } +} diff --git a/sounds/1.wav b/sounds/1.wav new file mode 100644 index 0000000..cbc9097 Binary files /dev/null and b/sounds/1.wav differ diff --git a/sounds/2.wav b/sounds/2.wav new file mode 100644 index 0000000..1c6853a Binary files /dev/null and b/sounds/2.wav differ diff --git a/sounds/3.wav b/sounds/3.wav new file mode 100644 index 0000000..aaf7590 Binary files /dev/null and b/sounds/3.wav differ diff --git a/sounds/4.wav b/sounds/4.wav new file mode 100644 index 0000000..2dbf78f Binary files /dev/null and b/sounds/4.wav differ diff --git a/sounds/5.wav b/sounds/5.wav new file mode 100644 index 0000000..86b48b3 Binary files /dev/null and b/sounds/5.wav differ diff --git a/sounds/6.wav b/sounds/6.wav new file mode 100644 index 0000000..39ae49f Binary files /dev/null and b/sounds/6.wav differ diff --git a/sounds/7.wav b/sounds/7.wav new file mode 100644 index 0000000..05b307b Binary files /dev/null and b/sounds/7.wav differ diff --git a/sounds/8.mp3 b/sounds/8.mp3 new file mode 100644 index 0000000..a117813 Binary files /dev/null and b/sounds/8.mp3 differ diff --git a/sounds/9.mp3 b/sounds/9.mp3 new file mode 100644 index 0000000..458838c Binary files /dev/null and b/sounds/9.mp3 differ