librfn
An ad-hoc utility library
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
tests
wavheadertest.c
Go to the documentation of this file.
1
/*
2
* wavheadertest.c
3
*
4
* Part of librfn (a general utility library from redfelineninja.org.uk)
5
*
6
* Copyright (C) 2012 Daniel Thompson <daniel@redfelineninja.org.uk>
7
*
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU Lesser General Public License as published
10
* by the Free Software Foundation; either version 3 of the License, or
11
* (at your option) any later version.
12
*/
13
14
#undef NDEBUG
15
16
#include <assert.h>
17
#include <stdio.h>
18
#include <stdlib.h>
19
#include <
string.h
>
20
21
#include <
librfn.h
>
22
23
int
main
()
24
{
25
rf_wavheader_t
in, out;
26
int
insz, outsz;
27
char
*s;
28
uint8_t
header
[128];
29
30
memset(&in, 0,
sizeof
(in));
31
verify
(0 !=
rf_wavheader_validate
(&in));
32
33
rf_wavheader_init
(&in, 44100, 1,
RF_WAVHEADER_FLOAT
);
34
verify
(0 ==
rf_wavheader_validate
(&in));
35
36
s =
rf_wavheader_tostring
(&in);
37
//printf("%s\n", s);
38
free(s);
39
40
insz =
rf_wavheader_encode
(&in, header,
sizeof
(header));
41
verify
(insz <
sizeof
(header));
42
43
outsz =
rf_wavheader_decode
(header, insz, &out);
44
verify
(insz == outsz);
45
verify
(0 == memcmp(&in, &out,
sizeof
(in)));
46
47
return
0;
48
}
string.h
rf_wavheader_decode
int rf_wavheader_decode(const uint8_t *p, unsigned int sz, rf_wavheader_t *wh)
Definition:
wavheader.c:29
rf_wavheader_tostring
char * rf_wavheader_tostring(rf_wavheader_t *wh)
Definition:
wavheader.c:211
rf_wavheader_init
void rf_wavheader_init(rf_wavheader_t *wh, int sfreq, int num_channels, rf_wavheader_format_t format)
Definition:
wavheader.c:154
verify
#define verify(x)
Definition:
util.h:55
header
struct usb_cdc_header_descriptor header
Definition:
console_cdcacm.c:91
rf_wavheader_encode
int rf_wavheader_encode(rf_wavheader_t *wh, uint8_t *p, unsigned int sz)
Definition:
wavheader.c:90
main
int main()
Definition:
wavheadertest.c:23
RF_WAVHEADER_FLOAT
Definition:
wavheader.h:58
librfn.h
rf_wavheader
Definition:
wavheader.h:28
rf_wavheader_validate
int rf_wavheader_validate(rf_wavheader_t *wh)
Definition:
wavheader.c:220
Generated on Sat Feb 6 2016 21:25:32 for librfn by
1.8.10