forked from tairrzayev/vinyl_decoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Releax BLACK_THRESHOLD value & optimize wav header initialization
Set BLACK_THRESHOLD to 100 down from 200 Avoid unnecessary wav_hdr copy when initializing it Update outdated reference to the WAV spec in the wav.h
- Loading branch information
1 parent
acfe93c
commit 746bb70
Showing
3 changed files
with
24 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,26 @@ | ||
#include <string.h> | ||
#include "wav.h" | ||
|
||
#define CHUNK_ID "RIFF" | ||
#define FORMAT "WAVE" | ||
#define SUBCHUNK1_ID "fmt " | ||
#define SUBCHUNK2_ID "data" | ||
|
||
//TODO: determine payload size dynamically | ||
struct wav_hdr mk_wav_hdr(uint32_t payload_size) | ||
void init_wav_hdr(struct wav_hdr *hdr, uint32_t payload_size) | ||
{ | ||
struct wav_hdr hdr; | ||
const char* chunk_id = "RIFF"; | ||
const char* format = "WAVE"; | ||
const char* subchunk1_id = "fmt "; | ||
const char* subchunk2_id = "data"; | ||
|
||
strncpy(hdr.chunk_id, chunk_id, strlen(chunk_id)); | ||
hdr.chunk_size = 0x6424; | ||
strncpy(hdr.format, format, strlen(format)); | ||
strncpy(hdr.subchunk1_id, subchunk1_id, strlen(subchunk1_id)); | ||
hdr.subchunk1_size = 0x10; | ||
hdr.audio_format = 0x01; | ||
hdr.channels = 0x01; | ||
hdr.sample_rate = 0x1F40; | ||
hdr.byte_rate = 0x1F40; | ||
hdr.block_align = 0x01; | ||
hdr.bits_per_sample = 0x08; | ||
strncpy(hdr.subchunk2_id, subchunk2_id, strlen(subchunk2_id)); | ||
hdr.subchunk2_size = 0x45A00; | ||
|
||
return hdr; | ||
memset(hdr, 0, sizeof(*hdr)); | ||
strncpy(hdr->chunk_id, CHUNK_ID, strlen(CHUNK_ID)); | ||
hdr->chunk_size = 0x6424; | ||
strncpy(hdr->format, FORMAT, strlen(FORMAT)); | ||
strncpy(hdr->subchunk1_id, SUBCHUNK1_ID, strlen(SUBCHUNK1_ID)); | ||
hdr->subchunk1_size = 0x10; | ||
hdr->audio_format = 0x01; | ||
hdr->channels = 0x01; | ||
hdr->sample_rate = 0x1F40; | ||
hdr->byte_rate = 0x1F40; | ||
hdr->block_align = 0x01; | ||
hdr->bits_per_sample = 0x08; | ||
strncpy(hdr->subchunk2_id, SUBCHUNK2_ID, strlen(SUBCHUNK2_ID)); | ||
hdr->subchunk2_size = 0x45A00; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters