2 wav_write.c - taken from wav-tools 1.1
3 Copyright (C) by Colin Ligertwood
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 11 Mar 1999: -added license hint
22 -added return statement in rewrite_head
24 20 Mar 1999: -using sys/types.h for type sizes for interplatform
27 22 Mar 1999: removed some wav-tools bugs (handling 8-Bit
28 values as 16Bit integers)
30 29 Apr 1999: hacked to use FILE* instead of file descriptors
38 #include <sys/soundcard.h>
46 void init_head(wav_sig *info){
50 strcpy(info->head, "RIFF WAVEfmt data ");
52 tmp32=(info->sofar + 32);
53 #ifdef BIG_ENDIAN_MACHINE
56 *(int32_t *)&info->head[4] = tmp32;
60 #ifdef BIG_ENDIAN_MACHINE
63 *(int32_t *)&info->head[16] = tmp32;
66 #ifdef BIG_ENDIAN_MACHINE
69 *(int16_t *)&info->head[20] = tmp16;
71 info->head[22] = info->chans;
75 #ifdef BIG_ENDIAN_MACHINE
78 *(int32_t *)&info->head[24] = tmp32;
81 #ifdef BIG_ENDIAN_MACHINE
84 *(int32_t *)&info->head[28] = tmp32;
86 info->head[32] = info->blkalign;
89 info->head[34] = info->depth;
93 #ifdef BIG_ENDIAN_MACHINE
96 *(int32_t *)&info->head[40] = tmp32;
99 FILE* open_wav_rec(wav_sig *info){
100 info->handle = fopen(info->name, "w");
102 fwrite(info->head, 44, 1, info->handle);
103 return(info->handle);
106 int rewrite_head(wav_sig *info){
107 rewind(info->handle);
109 fwrite(info->head, 44, 1, info->handle);