From 7008244a2db0398d6a57213f892c06520f621508 Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Fri, 26 Feb 2021 16:04:09 +0100 Subject: [PATCH] Add wavsmpl. --- README.md | 98 ++++++++++++++++++++++--------------------------------- mkfont.c | 9 ++--- wavsmpl.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+), 63 deletions(-) create mode 100644 wavsmpl.c diff --git a/README.md b/README.md index 877c598..83071cd 100644 --- a/README.md +++ b/README.md @@ -1,62 +1,42 @@ Random single-file programs I've written in my spare time for small tasks. -* bleep: I got bored and decided to write a pc speaker music program. -* ckmextract: Extracts ESP and BSA from Skyrim steam workshop mod archives. -* cube2enviro: A simple GL 4.4 program. Loads a cubemap and draws a flattened - hemisphere environment map that can be used in Unreal. -* ddsinfo: Shows contents of a DDS header. -* dood: Reads an ENDOOM lump and mirrors every word "down the middle". -* dtexdupes: Small tool I've used once or twice to clean up my doom projects of - duplicate textures. -* fmod\_playbank (formerly fuck\_fmod): Tool for playback of .fsb files. -* fuzz: A fancy blocky noise filter using proto-AliceGL designs. -* glfuzz: OpenGL version of the filter. -* iwad64ex: A small, failed experiment for ripping the Hexen 64 IWAD. -* lutconv: A program for converting various "3D" LUT textures to actual 3D LUTs - in DDS volume maps. Successor to mkvolume. Used for MariENB. Plus two - additional tools for "deconverting" volume maps, and one for smoothing them - out to reduce potential banding. -* mazestuff: A dungeon generator for roguelikes. This was made as part of a - commission for a friend, hence the very detailed comments. -* memrd/memsk/memwr: Quick 'n dirty tools for memory manipulation on running - programs. -* mkfont: A tool I use to convert UE fonts exported with UTPT into fonts for - GZDoom. Requires ImageMagick to be installed. -* mkgauss: Make an array of gaussian blur kernel values with passed radius and - sigma. Used for shader development. -* mksoundwad: Program used during the early days of Tim Allen Doom. Deprecated - as notsanae now also replaces sounds through an OpenAL hook. -* mkssao: Make an array of SSAO samples. Also for shader development. -* mkvolume: Old program for making LUT volume maps. -* mkwall: A program I use on a daily basis to set my wallpaper on every Linux - machine. -* osnorm: Experiment for generating object-space normals from an .obj model. -* pcxpalex.c: Extracts the palette from PCX images. -* pframes: Short utility for automating long FrameIndex lists for MODELDEF. -* schange: Program used along with mkwall to update the wallpaper on screen - geometry changes. -* skse_cosave: Experiment for dumping information in SKSE co-saves. -* soapstone: Random soapstone messages from all 3 dark souls games. Messages - can be generated in bulk. -* totty: Sends text from stdin to tty1. Used to send certain commands when - remoting into a Raspberry Pi. -* u95/u083/u086extract: Programs for extracting data from Unreal alpha - packages. This and other Unreal tools might be shifted to another repo. -* udmfvis: dmvis clone in C for UDMF maps. No external dependencies. -* ufontext: companion to mkfont, for extracting UE fonts. Currently does not - yet extract the textures themselves. -* umxunpack: Extractor for music in UE archives, with support for Unreal 227's - UMX files containing vorbis audio. -* unrundeleter: WIP program to unset the bDeleteMe flag on stuff in UE1 maps. - Yes, some mappers are so hellbent on preventing modification that they delete - all brushes after baking the geometry. -* usndextract: Extracts sounds from UE archives. -* utxextract: Extracts textures from UE archives. -* vc2sdl: Passes the contents of the VC4 framebuffer to a SDL window. Was used - for video playback experiments on a Raspberry Pi with a SPI LCD. -* wavrip: Cheap WAV file extractor that naively searchs for RIFF headers. -* withhands: Talk like W.D. Gaster. -* zimagekver: Quick program to extract version info from an ARM Linux kernel - image. +* **bleep:** I got bored and decided to write a pc speaker music program. +* **ckmextract:** Extracts ESP and BSA from Skyrim steam workshop mod archives. +* **cube2enviro:** A simple GL 4.4 program. Loads a cubemap and draws a flattened hemisphere environment map that can be used in Unreal. +* **ddsinfo:** Shows contents of a DDS header. +* **dood:** Reads an ENDOOM lump and mirrors every word "down the middle". +* **dtexdupes:** Small tool I've used once or twice to clean up my doom projects of duplicate textures. +* **fmod\_playbank (formerly fuck\_fmod):** Tool for playback of .fsb files. +* **fuzz:** A fancy blocky noise filter using proto-AliceGL designs. +* **glfuzz:** OpenGL version of the filter. +* **iwad64ex:** A small, failed experiment for ripping the Hexen 64 IWAD. +* **lutconv:** A program for converting various "3D" LUT textures to actual 3D LUTs in DDS volume maps. Successor to mkvolume. Used for MariENB. Plus two additional tools for "deconverting" volume maps, and one for smoothing them out to reduce potential banding. +* **mazestuff:** A dungeon generator for roguelikes. This was made as part of a commission for a friend, hence the very detailed comments. +* **memrd/memsk/memwr:** Quick 'n dirty tools for memory manipulation on running programs. +* **mkfont:** A tool I use to convert UE fonts exported with UTPT into fonts for GZDoom. Requires ImageMagick to be installed. +* **mkgauss:** Make an array of gaussian blur kernel values with passed radius and sigma. Used for shader development. +* **mksoundwad:** Program used during the early days of Tim Allen Doom. Deprecated as notsanae now also replaces sounds through an OpenAL hook. +* **mkssao:** Make an array of SSAO samples. Also for shader development. +* **mkvolume:** Old program for making LUT volume maps. +* **mkwall:** A program I use on a daily basis to set my wallpaper on every Linux machine. +* **osnorm:** Experiment for generating object-space normals from an .obj model. +* **pcxpalex:** Extracts the palette from PCX images. +* **pframes:** Short utility for automating long FrameIndex lists for MODELDEF. +* **schange:** Program used along with mkwall to update the wallpaper on screen geometry changes. +* **skse_cosave:** Experiment for dumping information in SKSE co-saves. +* **soapstone:** Random soapstone messages from all 3 dark souls games. Messages can be generated in bulk. +* **totty:** Sends text from stdin to tty1. Used to send certain commands when remoting into a Raspberry Pi. +* **u95/u083/u086extract:** Programs for extracting data from Unreal alpha packages. This and other Unreal tools might be shifted to another repo. +* **udmfvis:** dmvis clone in C for UDMF maps. No external dependencies. +* **ufontext:** companion to mkfont, for extracting UE fonts. Currently does not yet extract the textures themselves. +* **umxunpack:** Extractor for music in UE archives, with support for Unreal 227's UMX files containing vorbis audio. +* **unrundeleter:** WIP program to unset the bDeleteMe flag on stuff in UE1 maps. Yes, some mappers are so hellbent on preventing modification that they delete all brushes after baking the geometry. +* **usndextract:** Extracts sounds from UE archives. +* **utxextract:** Extracts textures from UE archives. +* **vc2sdl:** Passes the contents of the VC4 framebuffer to a SDL window. Was used for video playback experiments on a Raspberry Pi with a SPI LCD. +* **wavrip:** Cheap WAV file extractor that naively searchs for RIFF headers. +* **wavsmpl:** Extracts loop information from WAV files that have it, because only certain proprietary audio editors support this directly. +* **withhands:** Talk like W.D. Gaster. +* **zimagekver:** Quick program to extract version info from an ARM Linux kernel image. -All programs and code here are under the MIT license. +All programs and code here are under the MIT license. \ No newline at end of file diff --git a/mkfont.c b/mkfont.c index 763c767..332f8f2 100644 --- a/mkfont.c +++ b/mkfont.c @@ -6,9 +6,10 @@ int main( int argc, char **argv ) { - if ( argc < 3 ) return 1; + if ( argc < 2 ) return 1; char tname[256] = {0}; - int cell = 0, x = 0, y = 0, w = 0, h = 0; + unsigned cell = 0; + int x = 0, y = 0, w = 0, h = 0; char cropargs[256] = {0}; char cname[256] = {0}; char* hargs[7] = @@ -32,8 +33,8 @@ int main( int argc, char **argv ) } strcat(tname,".png"); if ( (w <= 0) || (h <= 0) ) continue; - printf("%d, %s %+d%+d,%d,%d\n",cell,tname,x,y,w,h); - sprintf(cname,"%s/%s_%03d.png",argv[1],argv[2],cell); + printf("%u, %s %+d%+d,%d,%d\n",cell,tname,x,y,w,h); + sprintf(cname,"%s/%04x.png",argv[1],cell); sprintf(cropargs,"%dx%d%+d%+d",w,h,x,y); int pid = fork(); if ( !pid ) execvp(hargs[0],hargs); diff --git a/wavsmpl.c b/wavsmpl.c new file mode 100644 index 0000000..49bc972 --- /dev/null +++ b/wavsmpl.c @@ -0,0 +1,89 @@ +#include +#include +#include +#include + +typedef struct +{ + char magic[4]; + uint32_t size; + char type[4]; +} riff_t; + +typedef struct +{ + char id[4]; + uint32_t size; +} chunk_t; + +typedef struct +{ + uint32_t mf, prod, sp, mnote, mpitch, sfmt, sofs, nloops, sdata; +} smpl_t; + +typedef struct +{ + uint32_t id, type, start, end, fraction, count; +} sloop_t; + +int main( int argc, char **argv ) +{ + if ( argc < 2 ) return 1; + FILE *fin; + for ( int i=1; i