Ktam3874/pitx software guide – Kontron KTAM3874-pITX User Manual

Page 113

Advertising
background image

KTD-S0057-I

Page 109 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide


The following sourcecode introduces a simple program for recording (capturing) and stores the data in a
WAV-file.

/***************************************************************
* Capture demo program

* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License.
****************************************************************/

#include <stdio.h>
#include <stdint.h>
#include <alsa/asoundlib.h>

#define FILENAME

"test.wav"

#define FRAMES

0x8000

#define MONO

1

#define STEREO

2

#define BUFSIZE

FRAMES * MONO

#define FMT_PCM

1

#define RATE_44kHz

44100

#define RATE_48kHz

48000

#define SAMPLEBITS 16

static char *device = "plughw:0,0";
static short buf[BUFSIZE];

typedef struct {
char

chunkId[4];

uint32_t

chunkSize;

char

format[4];

char

subChunkId[4];

uint32_t

subChunkSize;

uint16_t

audioFormat;

uint16_t

numChannels;

uint32_t

sampleRate;

uint32_t

byteRate;

uint16_t

blockAlign;

uint16_t

bitsPerSample;

char

subChunkId2[4];

uint32_t

subChunkSize2;

} wav_header;

Advertising
This manual is related to the following products: