Skip to content
Discussion options

You must be logged in to vote

This small program should do it:

#include <stdio.h> 

int main (void)
{
	FILE *fin = fopen ("sound.raw", "rb");
	if (fin == NULL)
	{
		return 1;
	}

	unsigned offset = 0;
	short value;
	while (fread (&value, sizeof value, 1, fin) == 1)
	{
		printf ("%d", (int) value);

		if (offset++ % 24 == 23)
		{
			printf (",\n");
		}
		else
		{
			printf (",");
		}
	}

	fclose (fin);

	return 0;
}

It expects the 16-bit signed audio samples in the file sound.raw (without header) and writes them to stdout. You must prepare a header file from this, like shown in the sample's README.

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@ABelliqueux
Comment options

@rsta2
Comment options

rsta2 May 7, 2025
Maintainer

@ABelliqueux
Comment options

@ABelliqueux
Comment options

@rsta2
Comment options

rsta2 May 8, 2025
Maintainer

Answer selected by ABelliqueux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants