### C++ Builder Package Installation for DCPcrypt Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/webSDK/dcpcrypt2-2009/Readme.txt Guide for installing DCPcrypt components in C++ Builder. This requires creating a new design-time package and adding all .pas files from the DCPcrypt2.zip archive, including those in subdirectories, followed by installation. ```cpp Create a new design time package and add all the .pas files from the DCPcrypt2.zip archive including all those in the Ciphers and Hashes subdirectories. Then press the install button. ``` -------------------------------- ### BASS Recording Start (C) Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/lib/bass/bass.txt This code demonstrates how to start recording with the BASS library, specifically handling cases where the device format changes on Windows and macOS. It uses BASS_RecordStart and the BASS_SYNC_DEV_FORMAT sync type. ```c // Start recording stream = BASS_RecordStart(44100, 1, 0, NULL, NULL); // Set a sync to handle device format changes BASS_ChannelSetSync(stream, BASS_SYNC_DEV_FORMAT, 0, SyncProc, 0); ``` -------------------------------- ### Apply GNU GPL to New Programs (Interactive Mode Notice) Source: https://github.com/ultrastar-deluxe/usdx/blob/master/game/fonts/wqy-microhei/LICENSE_GPLv3.txt This is an example of a short notice to be displayed by a program when it starts in interactive mode, indicating its copyright, licensing, and warranty status. This can be adapted for different programming languages and interfaces. ```text Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. ``` -------------------------------- ### Wildcard Example: STAT_OVERVIEW_INTRO - INI format Source: https://github.com/ultrastar-deluxe/usdx/blob/master/game/languages/README.md This illustrates the specific wildcards used in the STAT_OVERVIEW_INTRO string for displaying Ultrastar version and date information. It shows how to format day and month with leading zeros. ```INI %0:d Ultrastar Version %1:d Day of Reset (A1) %2:d Month of Reset (A2) %3:d Year of Reset (A3) ``` ```INI %1:.2d for the day and %2:.2d for the month ``` -------------------------------- ### BASS Recording Start Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/lib/bass/bass.txt Starts recording audio input from a specified device. The callback function receives recording data. User parameters are now pointers. Requires BASS library. ```c BASS_RecordStart(freq, chan, flags, proc, user); ``` -------------------------------- ### Build and Compile UltraStar Deluxe from Source Source: https://context7.com/ultrastar-deluxe/usdx/llms.txt Provides instructions for installing dependencies on Debian/Ubuntu systems and compiling the project using command-line tools or Lazarus IDE. Lists common configuration flags for the build process. ```bash # Install dependencies (Debian/Ubuntu) sudo apt-get install git automake make gcc fpc \ libsdl2-image-dev libavformat-dev libavcodec-dev \ libavutil-dev libswresample-dev libswscale-dev \ libsqlite3-dev libfreetype6-dev portaudio19-dev \ libportmidi-dev liblua5.3-dev fonts-dejavu # Clone and build git clone https://github.com/UltraStar-Deluxe/USDX cd USDX ./autogen.sh ./configure --enable-debug make ./game/ultrastardx # Configure flags: # --enable-debug : Enable debug logging and stacktraces # --without-portaudio : Use SDL audio instead of PortAudio # --with-opencv-cxx-api : Enable webcam support with OpenCV C++ API # Lazarus compilation: # 1. Open src/ultrastardx-unix.lpi (Linux/Mac) or src/ultrastardx-win.lpi (Windows) # 2. Choose Run → Build (Ctrl+F9) # 3. Executable: game/ultrastardx[.exe] # Directory structure after build: # game/ # ├── ultrastardx # Main executable # ├── songs/ # Song directory # ├── themes/ # Theme files # ├── languages/ # Translation files # ├── plugins/ # Lua plugins # └── config.ini # Configuration (created on first run) ``` -------------------------------- ### BASS Configuration Pointer Functions Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/lib/bass/bass.txt Allows setting and getting configuration options that use pointers. This includes network agent and proxy settings. Requires BASS library. ```c BASS_SetConfigPtr(option, pointer); BASS_GetConfigPtr(option); ``` -------------------------------- ### Kylix Package Installation for DCPcrypt Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/webSDK/dcpcrypt2-2009/Readme.txt Instructions for installing DCPcrypt components in Kylix. Users should open the DCPkylix.dpk package and click install. Kylix 1 users might need to create a new package, similar to C++ Builder. ```kylix Open the DCPkylix.dpk package and then press the install button (note: Kylix 1 users may need to create a new package as with C++ Builder as this is a Kylix 2 package). ``` -------------------------------- ### Delphi Package Installation for DCPcrypt Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/webSDK/dcpcrypt2-2009/Readme.txt Instructions for installing DCPcrypt components in Delphi. This involves opening the appropriate package file (DCPdelphiX.dpk) and clicking the install button. It ensures the cryptographic components are available on the component palette. ```delphi Open the appropriate package, DCPdelphiX.dpk where X is your version of Delphi (either 4, 5 or 6). Then press the install button. ``` -------------------------------- ### Bash: UltraStar Deluxe Command-Line Interface Options Source: https://context7.com/ultrastar-deluxe/usdx/llms.txt Provides examples of common command-line arguments for launching UltraStar Deluxe. These commands control various aspects of the game's startup, including enabling debug logging, running in benchmark mode without graphics, specifying custom configuration files, setting screen resolution, enabling fullscreen, loading specific songs, and displaying version information. ```bash # Launch with debug logging ./ultrastardx --debug # Start in benchmark mode (no graphics) ./ultrastardx --benchmark # Specify custom config file ./ultrastardx --configfile=/path/to/config.ini # Force specific screen resolution ./ultrastardx --resolution=1920x1080 # Enable fullscreen ./ultrastardx --fullscreen # Load specific song on startup ./ultrastardx --song="Artist - Title" # Display version information ./ultrastardx --version ``` -------------------------------- ### Wildcard Example: STAT_OVERVIEW_SONG - INI format Source: https://github.com/ultrastar-deluxe/usdx/blob/master/game/languages/README.md This shows the wildcards used in the STAT_OVERVIEW_SONG string for displaying song statistics, including counts of songs, sung songs, songs with videos, and the most popular song. ```INI %0:d Count Songs (A1) %1:d Count of Sung Songs (A2) %2:d Count of UnSung Songs %3:d Count of Songs with Video (A3) %4:s Name of the most popular Song ``` -------------------------------- ### Wildcard Example: STAT_OVERVIEW_PLAYER - INI format Source: https://github.com/ultrastar-deluxe/usdx/blob/master/game/languages/README.md This illustrates the wildcards used in the STAT_OVERVIEW_PLAYER string for displaying player statistics, including player counts, best player information, and best scores. ```INI %0:d Count Players (A1) %1:s Best Player (Result) %2:d Best Players Score %3:s Best Score Player (Result2) %4:d Best Score ``` -------------------------------- ### Apply GNU GPL to New Programs (Source File Notice) Source: https://github.com/ultrastar-deluxe/usdx/blob/master/game/fonts/wqy-microhei/LICENSE_GPLv3.txt This is a template for the notices to be attached to the start of each source file when applying the GNU General Public License to a new program. It includes copyright information, licensing terms, and warranty disclaimers. It is intended to be used in various programming languages. ```text Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ``` -------------------------------- ### BASS Recording Functions Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/lib/bass/bass.txt Provides essential functions for audio recording using the BASS library. This includes initializing recording, getting device descriptions, starting/stopping recording, and retrieving recording information. ```c BASS_RecordGetDeviceDescription(device); BASS_RecordInit(device); BASS_RecordFree(); BASS_RecordGetInfo(&info); BASS_RecordStart(channels, sampleRate, flags, proc, user); ``` -------------------------------- ### Wildcard Example: STAT_FORMAT_SINGERS - INI format Source: https://github.com/ultrastar-deluxe/usdx/blob/master/game/languages/README.md This illustrates the wildcards used in the STAT_FORMAT_SINGERS string for formatting singer statistics, showing the singer's name and their average score. ```INI %0:s Singer %1:d Average Score ``` -------------------------------- ### Wildcard Example: STAT_FORMAT_BANDS - INI format Source: https://github.com/ultrastar-deluxe/usdx/blob/master/game/languages/README.md This illustrates the wildcards used in the STAT_FORMAT_BANDS string for formatting band statistics, showing the artist name and the total number of times sung. ```INI %0:s Artist Name %1:d Times Sung ``` -------------------------------- ### Recording Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/lib/bass/bass.txt Functions for handling audio recording, including starting, stopping, and managing recording devices and streams. ```APIDOC ## Recording ### Description Provides functionality for audio recording. This includes initializing the recording system, selecting recording devices, starting and stopping recording, and processing recorded audio data. ### Methods - **BASS_RecordStart**: Starts recording audio. - **BASS_RecordStop**: Stops recording audio. - **BASS_RecordSetInput**: Sets the recording source. - **BASS_RecordGetInput**: Retrieves the current recording source. - **BASS_RecordGetLevel**: Retrieves the recording input level. - **BASS_RecordGetPosition**: Retrieves the recording position. ### Parameters #### BASS_RecordStart - **device** (number) - The recording device to use. Use -1 for the default device. - **freq** (number) - The recording frequency. - **flags** (number) - Recording flags. - **proc** (function) - Callback function for recorded data. - **user** (pointer) - User data for the callback. ### Request Example ```json { "function": "BASS_RecordStart", "parameters": { "device": -1, "freq": 44100, "flags": 0, "proc": null, "user": null } } ``` ### Response #### Success Response (200) - **handle** (HRECORD) - Handle to the recording session. - **error** (number) - BASS error code if unsuccessful. #### Response Example ```json { "handle": "" } ``` ``` -------------------------------- ### Wildcard Example: STAT_FORMAT_SONGS - INI format Source: https://github.com/ultrastar-deluxe/usdx/blob/master/game/languages/README.md This shows the wildcards used in the STAT_FORMAT_SONGS string for formatting song statistics, including artist, title, and the number of times sung. ```INI %0:s Artist %1:s Title %2:d Times Sung ``` -------------------------------- ### Dynamic Loading BASS Functions in C/C++ Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/lib/bass/bass.txt This example demonstrates how to dynamically load BASS functions using LoadLibrary and GetProcAddress in C/C++. It defines BASS functions as pointers and manually retrieves their addresses, allowing for flexible integration without direct linking. ```c #define BASSDEF(f) (WINAPI *f) // define the functions as pointers #include "bass.h" ... HISTHINSTANCE bass=LoadLibrary("BASS.DLL"); // load BASS BASS_Init=GetProcAddress(bass,"BASS_Init"); // get BASS_Init BASS_Init(-1,44100,0,hWnd,NULL); // call BASS_Init ``` -------------------------------- ### Wildcard Example: STAT_FORMAT_SCORES - INI format Source: https://github.com/ultrastar-deluxe/usdx/blob/master/game/languages/README.md This shows the wildcards used in the STAT_FORMAT_SCORES string for formatting individual score entries, including singer, score, difficulty, and song details. ```INI %0:s Singer %1:d Score %2:s Difficulty %3:s Song Artist %4:s Song Title ``` -------------------------------- ### Extracting Architectures from macOS BASS dylib Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/lib/bass/bass.txt This example shows how to use the provided makefile to extract specific architectures (x86_64, arm64, i386) from the universal BASS dylib on macOS. This is useful for reducing binary size or targeting specific architectures. ```makefile make x86_64 make arm64 make i386 make 64bit make intel ``` -------------------------------- ### BASS Stream Creation from URL (C) Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/lib/bass/bass.txt This code demonstrates how to create a stream from a URL using BASS, including handling auto-reconnection if a download stops before completion. It uses BASS_StreamCreateURL. The example also mentions that Internet streams now use HTTP/1.1 instead of HTTP/1.0. ```c // Create stream from URL HSTREAM stream = BASS_StreamCreateURL(url, 0, 0, NULL, NULL); // BASS_StreamCreateURL supports auto-reconnect for downloads. ``` -------------------------------- ### USDX Lua Plugin Initialization and Event Hook Source: https://github.com/ultrastar-deluxe/usdx/wiki/Lua-plugins This Lua code snippet demonstrates the basic structure for a USDX plugin. It includes the `plugin_init` function, which is called upon plugin loading, and how to register a hook for the 'Display.Draw' event. The `MyEveryFrameFunction` shows an example of executing code periodically, approximately once per second, by implementing a delay mechanism. ```lua -- minimum time between runs in milliseconds local Delay = 1000 local LastDraw = 0 function plugin_init() register('Dummy plugin', '1.00', 'PluginAuthor') hDraw = Usdx.Hook('Display.Draw', 'MyEveryFrameFunction') return true end function MyEveryFrameFunction() -- whatever you put in here runs every frame, hence the limiter local Now = Usdx.Time() if LastDraw + Delay > Now then return end -- whatever you put between here and the end of the function runs _close enough_ to once a second LastDraw = Now end ``` -------------------------------- ### Internet File Streaming from Offsets with BASS Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/lib/bass/bass.txt Supports streaming internet files starting from a specific byte offset. This is useful for resuming downloads or accessing specific parts of a remote file. ```c HSTREAM stream = BASS_StreamCreateURL(url, offset, 0, NULL, NULL); ``` -------------------------------- ### Initialize Cipher with Key and Hash Algorithm (Delphi) Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/webSDK/dcpcrypt2-2009/Docs/Index.html Demonstrates how to initialize a cipher component with a string key and specify the hash algorithm used for key generation. This ensures backward compatibility with previous versions by explicitly stating the hash algorithm, such as TDCP_sha1. ```delphi Cipher.InitStr('Hello World', TDCP_sha1); ``` -------------------------------- ### Lua: Creating Custom Game Modes with Plugins in UltraStar Deluxe Source: https://context7.com/ultrastar-deluxe/usdx/llms.txt Illustrates how to develop custom game modes for UltraStar Deluxe using Lua plugins. This example shows how to define plugin metadata, configure game mode properties like player and team counts, and hook into game events such as song selection and singing to implement custom logic for scoring and determining winners. ```lua -- Example plugin: game/plugins/teamduel.usdx (Lua code) function plugin_init() return { Name = "Team Duel", Version = "1.0", Author = "USDX Team", Url = "https://usdx.eu", -- Game mode configuration CanNonParty = false, CanParty = true, PlayerCount = 2 + 4, -- 2 or 3 players per team TeamCount = 2, -- Exactly 2 teams -- Event hooks BeforeSongSelect = "onBeforeSongSelect", AfterSing = "onAfterSing" } end function onBeforeSongSelect() -- Randomly select a song from the library local songCount = Songs.Count() local randomIndex = math.random(0, songCount - 1) Songs.SetSelected(randomIndex) end function onAfterSing() -- Custom scoring: winner takes all points local teams = Party.GetTeamRanking() if teams[1].Score > teams[2].Score then Party.SetWinner({1, 2}) -- Team 1 first, Team 2 second else Party.SetWinner({2, 1}) -- Team 2 first, Team 1 second end end ``` -------------------------------- ### Cipher Initialization with Hash Algorithm in Delphi Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/webSDK/dcpcrypt2-2009/Readme.txt Demonstrates how to initialize a cipher component in Delphi, explicitly specifying the hash algorithm used for key generation. This change ensures consistent functionality compared to previous versions, using TDCP_sha1 as an example. ```delphi Change the format of Cipher.InitStr so that the hash algorithm used to generate the key is explicitly specified. In order to get the same functionality as before, use TDCP_sha1. e.g. Cipher.InitStr('Hello World',TDCP_sha1); ``` -------------------------------- ### BASS Channel Device Management Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/lib/bass/bass.txt Allows moving an audio channel to a different output device. This is useful for multi-device audio setups. Requires BASS library. ```c BASS_ChannelSetDevice(handle, device); // Requires MULTI example update. ``` -------------------------------- ### Initialize RC4 Cipher with Passphrase (Pascal) Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/webSDK/dcpcrypt2-2009/Docs/Ciphers.html This code snippet demonstrates how to initialize the TDCP_rc4 cipher using a user-provided passphrase. It prompts the user for a passphrase, hashes it using SHA1, and then uses this hash to initialize the cipher. This is a common pattern for setting up secure communication. ```Pascal procedure TForm1.btnEncryptClick(Sender: TObject); var i: integer; Cipher: TDCP_rc4; KeyStr: string; begin KeyStr:= ''; if InputQuery('Passphrase','Enter passphrase',KeyStr) then // get the passphrase begin Cipher:= TDCP_rc4.Create(Self); Cipher.InitStr(KeyStr,TDCP_sha1); // initialize the cipher with a hash of the passphrase ``` -------------------------------- ### Wildcard Formatting Explanation - INI format Source: https://github.com/ultrastar-deluxe/usdx/blob/master/game/languages/README.md This demonstrates the general format for wildcards used in Ultrastar Deluxe language files, specifically for statistics screens. The format specifies how numbers and strings are represented and how optional decimal precision can be applied. ```INI %x:[.y]z ``` -------------------------------- ### Parse UltraStar Song Text Files in Pascal Source: https://context7.com/ultrastar-deluxe/usdx/llms.txt This snippet demonstrates how to load and parse song data from a custom text file format used by UltraStar Deluxe. It includes examples of metadata headers and note definitions, along with Pascal code to read and process this information. ```Pascal // Example song file: MySong.txt #TITLE:Dancing Queen #ARTIST:ABBA #MP3:song.mp3 #COVER:cover.jpg #VIDEO:background.mp4 #BPM:200 #GAP:5000 : 0 8 5 You : 8 8 7 can : 16 12 9 dance - 28 : 30 8 5 You : 38 8 7 can : 46 12 9 jive E // Loading a song in Pascal code (USong.pas) var Song: TSong; begin Song := TSong.Create(); if Song.LoadSong(Path('songs/ABBA - Dancing Queen/')) then begin WriteLn('Title: ', Song.Title); WriteLn('Artist: ', Song.Artist); WriteLn('BPM: ', FloatToStr(Song.BPM[0].BPM)); WriteLn('Note count: ', Length(Song.Tracks[0].Lines[0].Notes)); end; Song.Free; end; // Note format explanation: // : = regular note, * = golden note, F = freestyle note // : [start_beat] [duration] [pitch] [syllable] // - [beat] = line break // E = end of song ``` -------------------------------- ### Updating macOS BASS dylib to use @rpath Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/lib/bass/bass.txt This command updates older BASS and add-on dylibs to use the '@rpath' install path, which is the current standard for BASS versions 2.4.17 and later. This is necessary for correct loading of libraries on macOS. ```makefile make rpath ``` -------------------------------- ### Hash File Content with TDCP_ripemd160 Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/webSDK/dcpcrypt2-2009/Docs/Hashes.html This example shows how to hash the entire content of a file using the TDCP_ripemd160 algorithm. It opens a TFileStream, initializes the hash, updates it with the file's content via the stream, generates the final digest, and then displays it as a hexadecimal string. Error handling for file opening is included. ```Pascal procedure TForm1.Button1Click(Sender: TObject); var Hash: TDCP_ripemd160; Digest: array[0..19] of byte; _// RipeMD-160 produces a 160bit digest (20bytes)_ Source: TFileStream; i: integer; s: string; begin Source:= nil; try Source:= TFileStream.Create(Edit1.Text,fmOpenRead); _// open the file specified by Edit1_ except MessageDlg('Unable to open file',mtError, [mbOK],0); end; if Source <> nil then begin Hash:= TDCP_ripemd160.Create(Self); _// create the hash_ Hash.Init; _// initialize it_ Hash.UpdateStream(Source,Source.Size); _// hash the stream contents_ Hash.Final(Digest); _// produce the digest_ Source.Free; s:= ''; for i:= 0 to 19 do s:= s + IntToHex(Digest[i],2); Edit2.Text:= s; _// display the digest_ end; end; ``` -------------------------------- ### Example: Encrypt then Decrypt with Reset (Pascal) Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/webSDK/dcpcrypt2-2009/Docs/Ciphers.html This example illustrates the correct procedure for encrypting and then decrypting data using the RC4 cipher. It includes a call to 'Reset' between the encryption and decryption steps, ensuring that the chaining information is restored to its original state. This allows for successful decryption, and the function should return true. ```Pascal function TestCipher: boolean; const InData: array[0..9] of byte = ($01,$23,$45,$56,$67,$78,$89,$10,$AB,$FF); var Cipher: TDCP_rc4; Data: array[0..9] of byte; begin Cipher:= TDCP_rc4.Create(nil); Cipher.InitStr('Hello World',TDCP_sha1); // initialize the cipher Cipher.Encrypt(InData,Data,Sizeof(Data)); // encrypt some known data Cipher.Reset; // reset chaining information Cipher.Decrypt(Data,Data,Sizeof(Data)); // now decrypt it Cipher.Burn; // clear keying information Cipher.Free; Result:= CompareMem(@InData,@Data,Sizeof(Data)); // compare input and output end; ``` -------------------------------- ### Example: Encrypt then Decrypt without Reset (Pascal) Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/webSDK/dcpcrypt2-2009/Docs/Ciphers.html This example demonstrates encrypting and then attempting to decrypt data using the RC4 cipher. It intentionally omits the 'Reset' call, which will result in the decryption failing due to altered chaining information. This highlights the necessity of the 'Reset' procedure for correct decryption after encryption. ```Pascal function TestCipher: boolean; const InData: array[0..9] of byte = ($01,$23,$45,$56,$67,$78,$89,$10,$AB,$FF); var Cipher: TDCP_rc4; Data: array[0..9] of byte; begin Cipher:= TDCP_rc4.Create(nil); Cipher.InitStr('Hello World',TDCP_sha1); // initialize the cipher Cipher.Encrypt(InData,Data,Sizeof(Data)); // encrypt some known data Cipher.Decrypt(Data,Data,Sizeof(Data)); // now decrypt it Cipher.Burn; // clear keying information Cipher.Free; Result:= CompareMem(@InData,@Data,Sizeof(Data)); // compare input and output end; ``` -------------------------------- ### Initialization and Device Management Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/lib/bass/bass.txt Functions for initializing the BASS audio library, managing output and recording devices, and configuring global settings. ```APIDOC ## Initialization and Device Management ### Description Functions related to initializing the BASS audio library, selecting and managing audio output and recording devices, and configuring global settings. ### Methods - **BASS_Init**: Initializes a BASS device. - **BASS_SetDevice**: Sets the default output device. - **BASS_GetDevice**: Retrieves the default output device. - **BASS_ChannelGetDevice**: Retrieves the device associated with a channel. - **BASS_RecordInit**: Initializes BASS recording. - **BASS_RecordSetDevice**: Sets the default recording device. - **BASS_RecordGetDevice**: Retrieves the default recording device. - **BASS_SetConfig**: Sets a global configuration option. - **BASS_GetConfig**: Retrieves a global configuration option. ### Parameters #### BASS_Init - **device** (number) - The output device to use. Use -1 for the default device. - **freq** (number) - The frequency of the device. - **flags** (number) - Initialization flags. - **hwnd** (handle) - Window handle for the device. - **clsid** (GUID) - Class identifier for the device (optional). #### BASS_SetConfig - **option** (number) - The configuration option to set. - **value** (number) - The value to set for the option. ### Request Example ```json { "function": "BASS_Init", "parameters": { "device": -1, "freq": 44100, "flags": 0, "hwnd": null } } ``` ### Response #### Success Response (200) - **result** (boolean) - True if successful, false otherwise. - **error** (number) - BASS error code if unsuccessful. #### Response Example ```json { "result": true } ``` ``` -------------------------------- ### Pascal: Loading Lua Plugins in UltraStar Deluxe Source: https://context7.com/ultrastar-deluxe/usdx/llms.txt Shows how to load and manage Lua plugins within UltraStar Deluxe using the ULuaCore unit. This code demonstrates instance retrieval, loading a plugin from a specified path, checking its status, and accessing its metadata such as name, version, and author. It also covers pausing and resuming plugin execution. ```pascal // Loading plugins (ULuaCore.pas) uses ULuaCore, UPath; var LuaCore: TLuaCore; Plugin: TLuaPlugin; begin LuaCore := TLuaCore.GetInstance(); // Load plugin Plugin := LuaCore.LoadPlugin(Path('plugins/teamduel.usdx')); if Plugin.Status = psRunning then begin WriteLn('Plugin loaded: ', Plugin.Name); WriteLn('Version: ', Plugin.Version); WriteLn('Author: ', Plugin.Author); end else WriteLn('Plugin error: ', Plugin.Status); // Pause/resume plugin Plugin.Paused := True; Plugin.Paused := False; end; ``` -------------------------------- ### Initialize Audio Recording and List Devices in Pascal Source: https://context7.com/ultrastar-deluxe/usdx/llms.txt This code snippet shows how to initialize the audio recording subsystem in UltraStar Deluxe and list available input devices. It utilizes the URecord unit and iterates through the device list to display device names and channel counts. ```Pascal // Initialize recording (called in UMain.pas) uses URecord; var AudioInputProcessor: TAudioInputProcessor; begin AudioInputProcessor := TAudioInputProcessor.GetInstance(); // List available devices for i := 0 to AudioInputProcessor.DeviceList.Count - 1 do begin Device := AudioInputProcessor.DeviceList[i]; WriteLn('Device: ', Device.Name); WriteLn('Inputs: ', Device.AudioFormat.Channels); end; end; ``` -------------------------------- ### Pascal: Loading and Applying Themes in UltraStar Deluxe Source: https://context7.com/ultrastar-deluxe/usdx/llms.txt Demonstrates how to load and apply custom themes in UltraStar Deluxe using the UThemes unit. It shows how to create a TTheme object, load a theme file, access screen-specific data like background textures and button colors, and set custom backgrounds with different types (texture, color, video, etc.). ```pascal // Theme file structure: themes/Modern/Modern.ini [Skin] Name=Modern Creator=USDX Team [Color] Button=0.4,0.4,0.4 ButtonText=1,1,1 Background=0.1,0.1,0.1 // Loading and applying themes (UThemes.pas) uses UThemes, UPath; var Theme: TTheme; Background: TThemeBackground; begin Theme := TTheme.Create(Path('themes/Modern/Modern.ini')); Theme.LoadTheme(); // Access screen-specific theme data WriteLn('Main menu background: ', Theme.Song.Background.Tex); WriteLn('Button color: ', Theme.Song.Button.Color.R); // Set custom background Background.BGType := bgtTexture; Background.Tex := 'background.jpg'; Background.Alpha := 0.8; // Background types: bgtNone, bgtColor, bgtTexture, bgtVideo, bgtFade, bgtAuto Theme.Free; end; // Theme element positioning type TThemePosition = record X: integer; // Horizontal position (pixels) Y: integer; // Vertical position (pixels) W: integer; // Width (pixels) H: integer; // Height (pixels) end; // Example: Positioning a button var ButtonPos: TThemePosition; begin ButtonPos.X := 400; ButtonPos.Y := 300; ButtonPos.W := 200; ButtonPos.H := 50; end; ``` -------------------------------- ### Translate Untranslated Text - INI format Source: https://github.com/ultrastar-deluxe/usdx/blob/master/game/languages/README.md This format shows how to identify and translate lines in a language INI file. Lines prefixed with ';TODO:' are untranslated and need to be translated and have the prefix removed. Lines starting with ';INVALID:' or ';UNUSED:' should not be modified. ```INI ;TODO: SOME_OPTION=English text here ``` ```INI SOME_OPTION=Hier der deutsche Text ``` ```INI ;TRANSLATOR: Mario Translatori ``` -------------------------------- ### Initialize Graphics and Drawing Pipeline in UltraStar Deluxe Source: https://context7.com/ultrastar-deluxe/usdx/llms.txt Initializes the OpenGL context and SDL2 window for graphics rendering. Draws lyrics with syllable highlighting, showing progress through color changes. Relies on UGraphic.pas, UDraw.pas, dglOpenGL, and SDL2 libraries. ```pascal // Initialize graphics (UGraphic.pas) uses UGraphic, dglOpenGL, SDL2; procedure InitializeGraphics; begin // SDL2 window creation Window := SDL_CreateWindow( 'UltraStar Deluxe', SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1920, 1080, SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN ); // OpenGL context Context := SDL_GL_CreateContext(Window); SDL_GL_SetSwapInterval(1); // VSync // OpenGL initialization glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glClearColor(0.0, 0.0, 0.0, 1.0); end; // Draw lyrics with syllable highlighting (ULyrics.pas) procedure DrawLyrics(CurrentBeat: integer); var Line: TLine; Note: TLineFragment; Progress: real; begin Line := Tracks[0].Lines[CurrentLineIndex]; for i := 0 to Length(Line.Notes) - 1 do begin Note := Line.Notes[i]; // Calculate syllable progress if CurrentBeat >= Note.StartBeat then begin Progress := (CurrentBeat - Note.StartBeat) / Note.Duration; if Progress > 1.0 then Progress := 1.0; end else Progress := 0.0; // Draw syllable with color change based on progress glColor3f(0.8, 0.8, 0.8); // Unsung DrawText(Note.Text, XPos, YPos); if Progress > 0 then begin glColor3f(1.0, 1.0, 0.0); // Sung (yellow) DrawTextClipped(Note.Text, XPos, YPos, Progress); end; XPos := XPos + TextWidth(Note.Text); end; end; ``` -------------------------------- ### BASS Recording Device Initialization (C) Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/lib/bass/bass.txt This snippet demonstrates how to initialize the default recording device on Windows and macOS using the BASS library. It utilizes functions such as BASS_RecordInit and BASS_RecordGetDeviceInfo. The BASS_CONFIG_REC_DEFAULT option configures BASS to use the default recording device. ```c // Initialize default recording device BASS_RecordInit(0); // Get default recording device info BASS_DEVICEINFO di; BASS_RecordGetDeviceInfo(0, &di); // Configure BASS to use default recording device BASS_SetConfig(BASS_CONFIG_REC_DEFAULT, TRUE); ``` -------------------------------- ### BASS Initialization Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/lib/bass/bass.txt Initializes audio output and recording devices. This is a fundamental step before using most other BASS functions. Requires BASS library. ```c BASS_Init(device, freq, flags, hwnd, clsid); BASS_RecordInit(device); ``` -------------------------------- ### BASS Configuration Options Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/lib/bass/bass.txt Sets various configuration options for the BASS library, including network playlist handling, recording buffer size, and MP3 codec usage. Requires BASS library. ```c BASS_SetConfig(option, value); // Example options: // BASS_CONFIG_NET_PLAYLIST // BASS_CONFIG_REC_BUFFER // BASS_CONFIG_MP3_CODEC // BASS_CONFIG_MUSIC_VIRTUAL ``` -------------------------------- ### BASS Recording Initialization Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/lib/bass/bass.txt Initializes the recording device. This function is required before capturing audio input. Requires BASS library. ```c BASS_RecordInit(device); ``` -------------------------------- ### Channel Linking and Unlinking with BASS Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/lib/bass/bass.txt Allows multiple audio channels to be linked together for synchronized playback control (start, stop, pause, resume). This is useful for complex audio arrangements or soundscapes. ```c BASS_ChannelSetLink(chan1, chan2); BASS_ChannelRemoveLink(chan1, chan2); ``` -------------------------------- ### Encrypt/Decrypt Memo Text with TDCP_rc4 Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/webSDK/dcpcrypt2-2009/Docs/Ciphers.html Encrypts and decrypts the lines of a TMemo component using the TDCP_rc4 cipher. Requires user input for a passphrase to initialize the cipher. The cipher is burned and freed after use. ```delphi procedure TForm1.btnEncryptClick(Sender: TObject); var i: integer; Cipher: TDCP_rc4; KeyStr: string; begin KeyStr := ''; if InputQuery('Passphrase', 'Enter passphrase', KeyStr) then // get the passphrase begin Cipher := TDCP_rc4.Create(Self); Cipher.InitStr(KeyStr, TDCP_sha1); // initialize the cipher with a hash of the passphrase for i := 0 to Memo1.Lines.Count - 1 do // encrypt the contents of the memo Memo1.Lines[i] := Cipher.EncryptString(Memo1.Lines[i]); Cipher.Burn; Cipher.Free; end; end; procedure TForm1.btnDecryptClick(Sender: TObject); var i: integer; Cipher: TDCP_rc4; KeyStr: string; begin KeyStr := ''; if InputQuery('Passphrase', 'Enter passphrase', KeyStr) then // get the passphrase begin Cipher := TDCP_rc4.Create(Self); Cipher.InitStr(KeyStr, TDCP_sha1); // initialize the cipher with a hash of the passphrase for i := 0 to Memo1.Lines.Count - 1 do // decrypt the contents of the memo Memo1.Lines[i] := Cipher.DecryptString(Memo1.Lines[i]); Cipher.Burn; Cipher.Free; end; end; ``` -------------------------------- ### Manage Game Configuration Source: https://context7.com/ultrastar-deluxe/usdx/llms.txt Handles loading and saving game settings from an INI file located in the user's home directory. It manages various settings including language, graphics, sound, directories, and input devices. ```pascal // Configuration file: ~/.ultrastardx/config.ini [Game] Language=English Tabs=On Sorting=Artist Difficulty=Easy [Graphics] Resolution=1920x1080 FullScreen=On Screens=1 [Sound] PreviewVolume=70 PreviewFading=3 [Directories] SongDir1=/home/user/Music/UltraStarSongs SongDir2=/media/songs [Input] Joypad=On // Loading configuration (UIni.pas) uses UIni, UPath; var Ini: TIni; begin Ini := TIni.Create; Ini.Load(); WriteLn('Language: ', Ini.Language); WriteLn('Resolution: ', Ini.Resolution); WriteLn('Preview Volume: ', Ini.PreviewVolume); // Modify settings Ini.Difficulty := 2; // Medium Ini.FullScreen := True; Ini.Save(); Ini.Free; end; // Input device configuration var DeviceConfig: TInputDeviceConfig; begin DeviceConfig.Name := 'Microphone (USB Audio)'; DeviceConfig.Input := 0; DeviceConfig.Latency := LATENCY_AUTODETECT; // Map channels to players SetLength(DeviceConfig.ChannelToPlayerMap, 2); DeviceConfig.ChannelToPlayerMap[0] := 1; // Left channel -> Player 1 DeviceConfig.ChannelToPlayerMap[1] := 2; // Right channel -> Player 2 end; ``` -------------------------------- ### BASS Configuration Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/lib/bass/bass.txt Functions for configuring BASS settings, including network options, file verification, and codec preferences. ```APIDOC ## BASS Configuration ### Description Provides functions to configure various aspects of the BASS library, such as network settings, file processing, and audio parameters. ### Functions * **BASS_SetConfigPtr**: Sets a configuration option that takes a pointer. * **BASS_GetConfigPtr**: Gets a configuration option that takes a pointer. * **BASS_SetConfig**: Sets a configuration option. * **BASS_GetVersion**: Retrieves the version of the BASS library. ### Configuration Options * **BASS_CONFIG_NET_AGENT**: Sets the network agent. * **BASS_CONFIG_NET_PROXY**: Configures proxy server settings. * **BASS_CONFIG_NET_NOPROXY**: *Removed*. * **BASS_CONFIG_NET_PLAYLIST**: Enables PLS/M3U playlist URL processing. * **BASS_CONFIG_NET_PASSIVE**: Enables passive FTP mode. * **BASS_CONFIG_VERIFY**: Sets the file format verification length. * **BASS_CONFIG_REC_BUFFER**: Sets the adjustable recording buffer size. * **BASS_CONFIG_MUSIC_VIRTUAL**: Configures IT virtual channel settings. * **BASS_CONFIG_MP3_CODEC**: Optional use of the Windows MP3 codec. * **BASS_CONFIG_MP3_CODEC *removed***: Previous option for MP3 codec configuration. ### Structures * **BASS_INFO (driver member)**: *Removed*. * **BASS_RECORDINFO (driver member)**: *Removed*. ``` -------------------------------- ### Encrypt/Decrypt File with TDCP_rc4 Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/webSDK/dcpcrypt2-2009/Docs/Ciphers.html Encrypts and decrypts the contents of a file using the TDCP_rc4 cipher. Reads input from boxInputFile and writes output to boxOutputFile. Includes error handling for file operations. Requires user input for a passphrase. ```delphi procedure TForm1.btnEncryptClick(Sender: TObject); var Cipher: TDCP_rc4; KeyStr: string; Source, Dest: TFileStream; begin KeyStr := ''; if InputQuery('Passphrase', 'Enter passphrase', KeyStr) then // get the passphrase begin try Source := TFileStream.Create(boxInputFile.Text, fmOpenRead); Dest := TFileStream.Create(boxOutputFile.Text, fmCreate); Cipher := TDCP_rc4.Create(Self); Cipher.InitStr(KeyStr, TDCP_sha1); // initialize the cipher with a hash of the passphrase Cipher.EncryptStream(Source, Dest, Source.Size); // encrypt the contents of the file Cipher.Burn; Cipher.Free; Dest.Free; Source.Free; MessageDlg('File encrypted', mtInformation, [mbOK], 0); except MessageDlg('File IO error', mtError, [mbOK], 0); end; end; end; procedure TForm1.btnDecryptClick(Sender: TObject); var Cipher: TDCP_rc4; KeyStr: string; Source, Dest: TFileStream; begin KeyStr := ''; if InputQuery('Passphrase', 'Enter passphrase', KeyStr) then // get the passphrase begin try Source := TFileStream.Create(boxInputFile.Text, fmOpenRead); Dest := TFileStream.Create(boxOutputFile.Text, fmCreate); Cipher := TDCP_rc4.Create(Self); Cipher.InitStr(KeyStr, TDCP_sha1); // initialize the cipher with a hash of the passphrase Cipher.DecryptStream(Source, Dest, Source.Size); // decrypt the contents of the file Cipher.Burn; Cipher.Free; Dest.Free; Source.Free; MessageDlg('File decrypted', mtInformation, [mbOK], 0); except MessageDlg('File IO error', mtError, [mbOK], 0); end; end; end; ``` -------------------------------- ### Compile UltraStar Deluxe using Autotools (Shell) Source: https://github.com/ultrastar-deluxe/usdx/blob/master/README.md This command sequence outlines the process for compiling UltraStar Deluxe using the autotools build system. It includes steps for generating the configure script, configuring the build with optional debug flags, and then making the executable. The final executable is located in the 'game/' directory. ```shell ./autogen.sh && ./configure [--enable-debug] && make The executable will be "game/ultrastardx[.exe]". ``` -------------------------------- ### BASS Device Management and Info Source: https://github.com/ultrastar-deluxe/usdx/blob/master/src/lib/bass/bass.txt Functions and structures related to retrieving information about audio devices and their capabilities. ```APIDOC ## BASS Device Management and Info ### Description Provides functions to initialize audio devices, retrieve device descriptions, and access system audio information. ### Functions * **BASS_Init**: Initializes a device for playback. * **BASS_RecordInit**: Initializes a device for recording. * **BASS_GetDeviceDescription**: Retrieves a description of an audio device. * **BASS_RecordGetDeviceDescription**: Retrieves a description of a recording device. ### Structures * **BASS_DEVICEINFO**: Structure containing information about an audio device. * **BASS_INFO**: Structure containing general information about the BASS system, including driver and speaker configuration. * **BASS_RECORDINFO**: Structure containing information about the recording device, including driver and frequency. ### Flags * **BASS_DEVICE_CPSPEAKERS**: Flag for BASS_Init to indicate speaker detection from the Windows control panel. ```