Add wavsmpl.

This commit is contained in:
Marisa the Magician 2021-02-26 16:04:09 +01:00
commit 7008244a2d
3 changed files with 133 additions and 63 deletions

View file

@ -1,62 +1,42 @@
Random single-file programs I've written in my spare time for small tasks. 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. * **bleep:** I got bored and decided to write a pc speaker music program.
* ckmextract: Extracts ESP and BSA from Skyrim steam workshop mod archives. * **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 * **cube2enviro:** A simple GL 4.4 program. Loads a cubemap and draws a flattened hemisphere environment map that can be used in Unreal.
hemisphere environment map that can be used in Unreal. * **ddsinfo:** Shows contents of a DDS header.
* ddsinfo: Shows contents of a DDS header. * **dood:** Reads an ENDOOM lump and mirrors every word "down the middle".
* 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.
* dtexdupes: Small tool I've used once or twice to clean up my doom projects of * **fmod\_playbank (formerly fuck\_fmod):** Tool for playback of .fsb files.
duplicate textures. * **fuzz:** A fancy blocky noise filter using proto-AliceGL designs.
* fmod\_playbank (formerly fuck\_fmod): Tool for playback of .fsb files. * **glfuzz:** OpenGL version of the filter.
* fuzz: A fancy blocky noise filter using proto-AliceGL designs. * **iwad64ex:** A small, failed experiment for ripping the Hexen 64 IWAD.
* glfuzz: OpenGL version of the filter. * **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.
* iwad64ex: A small, failed experiment for ripping the Hexen 64 IWAD. * **mazestuff:** A dungeon generator for roguelikes. This was made as part of a commission for a friend, hence the very detailed comments.
* lutconv: A program for converting various "3D" LUT textures to actual 3D LUTs * **memrd/memsk/memwr:** Quick 'n dirty tools for memory manipulation on running programs.
in DDS volume maps. Successor to mkvolume. Used for MariENB. Plus two * **mkfont:** A tool I use to convert UE fonts exported with UTPT into fonts for GZDoom. Requires ImageMagick to be installed.
additional tools for "deconverting" volume maps, and one for smoothing them * **mkgauss:** Make an array of gaussian blur kernel values with passed radius and sigma. Used for shader development.
out to reduce potential banding. * **mksoundwad:** Program used during the early days of Tim Allen Doom. Deprecated as notsanae now also replaces sounds through an OpenAL hook.
* mazestuff: A dungeon generator for roguelikes. This was made as part of a * **mkssao:** Make an array of SSAO samples. Also for shader development.
commission for a friend, hence the very detailed comments. * **mkvolume:** Old program for making LUT volume maps.
* memrd/memsk/memwr: Quick 'n dirty tools for memory manipulation on running * **mkwall:** A program I use on a daily basis to set my wallpaper on every Linux machine.
programs. * **osnorm:** Experiment for generating object-space normals from an .obj model.
* mkfont: A tool I use to convert UE fonts exported with UTPT into fonts for * **pcxpalex:** Extracts the palette from PCX images.
GZDoom. Requires ImageMagick to be installed. * **pframes:** Short utility for automating long FrameIndex lists for MODELDEF.
* mkgauss: Make an array of gaussian blur kernel values with passed radius and * **schange:** Program used along with mkwall to update the wallpaper on screen geometry changes.
sigma. Used for shader development. * **skse_cosave:** Experiment for dumping information in SKSE co-saves.
* mksoundwad: Program used during the early days of Tim Allen Doom. Deprecated * **soapstone:** Random soapstone messages from all 3 dark souls games. Messages can be generated in bulk.
as notsanae now also replaces sounds through an OpenAL hook. * **totty:** Sends text from stdin to tty1. Used to send certain commands when remoting into a Raspberry Pi.
* mkssao: Make an array of SSAO samples. Also for shader development. * **u95/u083/u086extract:** Programs for extracting data from Unreal alpha packages. This and other Unreal tools might be shifted to another repo.
* mkvolume: Old program for making LUT volume maps. * **udmfvis:** dmvis clone in C for UDMF maps. No external dependencies.
* mkwall: A program I use on a daily basis to set my wallpaper on every Linux * **ufontext:** companion to mkfont, for extracting UE fonts. Currently does not yet extract the textures themselves.
machine. * **umxunpack:** Extractor for music in UE archives, with support for Unreal 227's UMX files containing vorbis audio.
* osnorm: Experiment for generating object-space normals from an .obj model. * **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.
* pcxpalex.c: Extracts the palette from PCX images. * **usndextract:** Extracts sounds from UE archives.
* pframes: Short utility for automating long FrameIndex lists for MODELDEF. * **utxextract:** Extracts textures from UE archives.
* schange: Program used along with mkwall to update the wallpaper on screen * **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.
geometry changes. * **wavrip:** Cheap WAV file extractor that naively searchs for RIFF headers.
* skse_cosave: Experiment for dumping information in SKSE co-saves. * **wavsmpl:** Extracts loop information from WAV files that have it, because only certain proprietary audio editors support this directly.
* soapstone: Random soapstone messages from all 3 dark souls games. Messages * **withhands:** Talk like W.D. Gaster.
can be generated in bulk. * **zimagekver:** Quick program to extract version info from an ARM Linux kernel image.
* 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.
All programs and code here are under the MIT license. All programs and code here are under the MIT license.

View file

@ -6,9 +6,10 @@
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
if ( argc < 3 ) return 1; if ( argc < 2 ) return 1;
char tname[256] = {0}; 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 cropargs[256] = {0};
char cname[256] = {0}; char cname[256] = {0};
char* hargs[7] = char* hargs[7] =
@ -32,8 +33,8 @@ int main( int argc, char **argv )
} }
strcat(tname,".png"); strcat(tname,".png");
if ( (w <= 0) || (h <= 0) ) continue; if ( (w <= 0) || (h <= 0) ) continue;
printf("%d, %s %+d%+d,%d,%d\n",cell,tname,x,y,w,h); printf("%u, %s %+d%+d,%d,%d\n",cell,tname,x,y,w,h);
sprintf(cname,"%s/%s_%03d.png",argv[1],argv[2],cell); sprintf(cname,"%s/%04x.png",argv[1],cell);
sprintf(cropargs,"%dx%d%+d%+d",w,h,x,y); sprintf(cropargs,"%dx%d%+d%+d",w,h,x,y);
int pid = fork(); int pid = fork();
if ( !pid ) execvp(hargs[0],hargs); if ( !pid ) execvp(hargs[0],hargs);

89
wavsmpl.c Normal file
View file

@ -0,0 +1,89 @@
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
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<argc; i++ )
{
if ( !(fin = fopen(argv[i],"rb")) )
{
fprintf(stderr,"couldn't open %s: %s\n",argv[i],strerror(errno));
continue;
}
riff_t head;
if ( fread(&head,1,sizeof(riff_t),fin) != sizeof(riff_t) )
{
fprintf(stderr,"%s: premature end of file reached reading file header\n",argv[i]);
goto skipme;
}
if ( strncmp(head.magic,"RIFF",4) )
{
fprintf(stderr,"%s: invalid RIFF header\n",argv[i]);
goto skipme;
}
while ( !feof(fin) )
{
chunk_t chk;
if ( fread(&chk,1,sizeof(chunk_t),fin) != sizeof(chunk_t) )
{
fprintf(stderr,"%s: premature end of file reached reading chunk header\n",argv[i]);
goto skipme;
}
if ( strncmp(chk.id,"smpl",4) )
{
printf("Skipping over %.4s chunk (%u bytes)\n",chk.id,chk.size);
fseek(fin,chk.size,SEEK_CUR);
continue;
}
printf("smpl chunk found\n");
smpl_t smpl;
if ( fread(&smpl,1,sizeof(smpl_t),fin) != sizeof(smpl_t) )
{
fprintf(stderr,"%s: premature end of file reached reading smpl data\n",argv[i]);
goto skipme;
}
printf("%u loops contained\n",smpl.nloops);
for ( uint32_t j=0; j<smpl.nloops; j++ )
{
sloop_t loop;
if ( fread(&loop,1,sizeof(sloop_t),fin) != sizeof(sloop_t) )
{
fprintf(stderr,"%s: premature end of file reached reading smpl loop\n",argv[i]);
goto skipme;
}
printf("ID: %u\n type: %u\n start: %u\n end: %u\n fraction: %u\n count: %u\n",
loop.id,loop.type,loop.start,loop.end,loop.fraction,loop.count);
}
}
skipme:
fclose(fin);
}
return 0;
}