Skip to content

Commit

Permalink
Merge pull request #20 from vmedea/audio-comments
Browse files Browse the repository at this point in the history
Add comments regarding ADPCM block sizes
  • Loading branch information
dan-rodrigues authored Nov 13, 2020
2 parents 7ec4666 + 4fa43bd commit f57aef4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion hardware/ics_adpcm.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

module ics_adpcm #(
parameter integer OUTPUT_INTERVAL = 33700000 / 44100,
parameter [15:0] ADPCM_BLOCK_SIZE = 1024 * 2,
parameter [15:0] ADPCM_BLOCK_SIZE = 1024 * 2, // in nibbles
parameter [3:0] CHANNELS = 8,
parameter ADPCM_STEP_LUT_PATH = "adpcm_step_lut.hex",

Expand Down
2 changes: 1 addition & 1 deletion software/lib/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void audio_set_aligned_addresses(volatile AudioChannel *channel, const int16_t *

void audio_aligned_addresses(const int16_t *start, size_t length, AudioAlignedAddresses *addresses) {
const uintptr_t cpu_flash_base = 0x1000000;
const size_t adpcm_block_size = 0x400;
const size_t adpcm_block_size = 0x400; // in bytes

uintptr_t block_start = (((size_t)start - cpu_flash_base)) / adpcm_block_size;
uintptr_t block_end = block_start + (length + (adpcm_block_size / 2 - 1)) / (adpcm_block_size / 2);
Expand Down
9 changes: 9 additions & 0 deletions software/lib/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,17 @@ typedef struct {
uint16_t loop;
} AudioAlignedAddresses;

/**
* Set sample start address and length for a channel. The specified length is in
* 16-bit units. The loop address will be the same as the end address, so if
* looping is enabled the entire sample will loop.
*/
void audio_set_aligned_addresses(volatile AudioChannel *channel, const int16_t *start, size_t length);

/**
* Compute sample start address and length for a channel. The specified length
* is in 16-bit units.
*/
void audio_aligned_addresses(const int16_t *start, size_t length, AudioAlignedAddresses *addresses);

#endif /* audio_h */

0 comments on commit f57aef4

Please sign in to comment.