Initial commit, setup basic imgloading

This commit is contained in:
2026-02-04 03:48:33 -06:00
commit be086e4540
4 changed files with 8051 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
# datasets / generated files
esc-50-audio/
# executable
soundknn.exe

16
README.md Normal file
View File

@@ -0,0 +1,16 @@
# Purpose
Run knn on audio data which has been converted to images to find similar audio clips
## Ffmpeg preporcessing command
`for %f in (*.wav) do ffmpeg -y -i "%f" -ar 44100 -lavfi "showspectrumpic=s=256x256:scale=log:legend=0" "img\%~nf.png"`
## stb_image.h
Used for gathering the image data
## Building
`clang src/main.c -Iexternal -O2 -o soundknn.exe`
### Todo
- Load all images from directory
- Do knn algorithm
- Use opencl to accelerate algorithm execution

7988
external/stb_image.h vendored Normal file

File diff suppressed because it is too large Load Diff

42
src/main.c Normal file
View File

@@ -0,0 +1,42 @@
#include <stdio.h>
#include <windows.h>
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
struct AudioData{
unsigned char *data;
char *fileName;
};
int main(){
int x,y;
// Loads data into 1D array 256x256 so 2nd row starts at 256
struct AudioData audioData[2];
audioData[0].data= stbi_load("esc-50-audio/img/1-137-A-32.png", &x, &y, NULL, 1);
audioData[1].data = stbi_load("esc-50-audio/img/1-977-A-39.png", &x, &y, NULL, 1);
if (!audioData[0].data) {
printf("Failed to load image: %s\n", stbi_failure_reason());
return 1;
}
if (!audioData[1].data) {
printf("Failed to load image: %s\n", stbi_failure_reason());
return 1;
}
for(int i=11766;i<12766;i++){
if(audioData[0].data[i]!=0){
printf("img1 info: %u",audioData[0].data[i]);
printf("\n");
}
}
for(int i=11766;i<12766;i++){
if(audioData[1].data[i]!=0){
printf("img2 info: %u",audioData[1].data[i]);
printf("\n");
}
}
return 0;
}