To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
The primary repository for this project is hosted at https://github.com/sonic-visualiser/sv-dependency-builds .
This repository is a read-only copy which is updated automatically every hour.
root / src / portaudio_20161030_catalina_patch / qa / loopback / src / write_wav.h @ 162:d43aab368df9
History | View | Annotate | Download (3.7 KB)
| 1 |
/*
|
|---|---|
| 2 |
* PortAudio Portable Real-Time Audio Library
|
| 3 |
* Latest Version at: http://www.portaudio.com
|
| 4 |
*
|
| 5 |
* Copyright (c) 1999-2010 Phil Burk and Ross Bencina
|
| 6 |
*
|
| 7 |
* Permission is hereby granted, free of charge, to any person obtaining
|
| 8 |
* a copy of this software and associated documentation files
|
| 9 |
* (the "Software"), to deal in the Software without restriction,
|
| 10 |
* including without limitation the rights to use, copy, modify, merge,
|
| 11 |
* publish, distribute, sublicense, and/or sell copies of the Software,
|
| 12 |
* and to permit persons to whom the Software is furnished to do so,
|
| 13 |
* subject to the following conditions:
|
| 14 |
*
|
| 15 |
* The above copyright notice and this permission notice shall be
|
| 16 |
* included in all copies or substantial portions of the Software.
|
| 17 |
*
|
| 18 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 19 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 20 |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
| 21 |
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
| 22 |
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
| 23 |
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
| 24 |
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 25 |
*/
|
| 26 |
|
| 27 |
/*
|
| 28 |
* The text above constitutes the entire PortAudio license; however,
|
| 29 |
* the PortAudio community also makes the following non-binding requests:
|
| 30 |
*
|
| 31 |
* Any person wishing to distribute modifications to the Software is
|
| 32 |
* requested to send the modifications to the original developer so that
|
| 33 |
* they can be incorporated into the canonical version. It is also
|
| 34 |
* requested that these non-binding requests be included along with the
|
| 35 |
* license above.
|
| 36 |
*/
|
| 37 |
#ifndef _WAV_WRITER_H
|
| 38 |
#define _WAV_WRITER_H
|
| 39 |
|
| 40 |
/*
|
| 41 |
* WAV file writer.
|
| 42 |
*
|
| 43 |
* Author: Phil Burk
|
| 44 |
*/
|
| 45 |
|
| 46 |
#ifdef __cplusplus
|
| 47 |
extern "C" { |
| 48 |
#endif
|
| 49 |
|
| 50 |
/* Define WAV Chunk and FORM types as 4 byte integers. */
|
| 51 |
#define RIFF_ID (('R'<<24) | ('I'<<16) | ('F'<<8) | 'F') |
| 52 |
#define WAVE_ID (('W'<<24) | ('A'<<16) | ('V'<<8) | 'E') |
| 53 |
#define FMT_ID (('f'<<24) | ('m'<<16) | ('t'<<8) | ' ') |
| 54 |
#define DATA_ID (('d'<<24) | ('a'<<16) | ('t'<<8) | 'a') |
| 55 |
#define FACT_ID (('f'<<24) | ('a'<<16) | ('c'<<8) | 't') |
| 56 |
|
| 57 |
/* Errors returned by Audio_ParseSampleImage_WAV */
|
| 58 |
#define WAV_ERR_CHUNK_SIZE (-1) /* Chunk size is illegal or past file size. */ |
| 59 |
#define WAV_ERR_FILE_TYPE (-2) /* Not a WAV file. */ |
| 60 |
#define WAV_ERR_ILLEGAL_VALUE (-3) /* Illegal or unsupported value. Eg. 927 bits/sample */ |
| 61 |
#define WAV_ERR_FORMAT_TYPE (-4) /* Unsupported format, eg. compressed. */ |
| 62 |
#define WAV_ERR_TRUNCATED (-5) /* End of file missing. */ |
| 63 |
|
| 64 |
/* WAV PCM data format ID */
|
| 65 |
#define WAVE_FORMAT_PCM (1) |
| 66 |
#define WAVE_FORMAT_IMA_ADPCM (0x0011) |
| 67 |
|
| 68 |
|
| 69 |
typedef struct WAV_Writer_s |
| 70 |
{
|
| 71 |
FILE *fid; |
| 72 |
/* Offset in file for data size. */
|
| 73 |
int dataSizeOffset;
|
| 74 |
int dataSize;
|
| 75 |
} WAV_Writer; |
| 76 |
|
| 77 |
/*********************************************************************************
|
| 78 |
* Open named file and write WAV header to the file.
|
| 79 |
* The header includes the DATA chunk type and size.
|
| 80 |
* Returns number of bytes written to file or negative error code.
|
| 81 |
*/
|
| 82 |
long Audio_WAV_OpenWriter( WAV_Writer *writer, const char *fileName, int frameRate, int samplesPerFrame ); |
| 83 |
|
| 84 |
/*********************************************************************************
|
| 85 |
* Write to the data chunk portion of a WAV file.
|
| 86 |
* Returns bytes written or negative error code.
|
| 87 |
*/
|
| 88 |
long Audio_WAV_WriteShorts( WAV_Writer *writer,
|
| 89 |
short *samples,
|
| 90 |
int numSamples
|
| 91 |
); |
| 92 |
|
| 93 |
/*********************************************************************************
|
| 94 |
* Close WAV file.
|
| 95 |
* Update chunk sizes so it can be read by audio applications.
|
| 96 |
*/
|
| 97 |
long Audio_WAV_CloseWriter( WAV_Writer *writer );
|
| 98 |
|
| 99 |
#ifdef __cplusplus
|
| 100 |
}; |
| 101 |
#endif
|
| 102 |
|
| 103 |
#endif /* _WAV_WRITER_H */ |