view sw/mcsi-rxtx/record.c @ 13:315428573a25

fc-mcsi-rxtx: implement record function
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 28 Oct 2024 07:24:53 +0000
parents
children
line wrap: on
line source

/*
 * Here we implement the functionality of recording MCSI Rx streams
 * into robe files.
 */

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>

extern u_short rx_pcm_samples[160];

static FILE *record_file;

void
record_process()
{
	unsigned n, samp;

	if (!record_file)
		return;
	for (n = 0; n < 160; n++) {
		samp = rx_pcm_samples[n];
		putc(samp >> 8, record_file);
		putc(samp, record_file);
	}
}

void
record_auto_stop()
{
	if (!record_file)
		return;
	fclose(record_file);
	record_file = 0;
}

void
cmd_record(argc, argv)
	char **argv;
{
	if (record_file) {
		printf("error: recording already in progress\n");
		return;
	}
	record_file = fopen(argv[1], "w");
	if (!record_file)
		perror(argv[1]);
}

void
cmd_record_stop()
{
	if (!record_file) {
		printf("error: no recording in progress\n");
		return;
	}
	fclose(record_file);
	record_file = 0;
}