Skip to content

Commit

Permalink
fix pre/post usb audio routing
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Klang committed Mar 27, 2022
1 parent bc408a0 commit 74de899
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
16 changes: 6 additions & 10 deletions Source/ProgramManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ static uint32_t usbd_audio_rx_count = 0;
/* Get number of samples transmitted since previous request */
uint32_t usbd_audio_get_rx_count(){
// return 0;
uint32_t pos = usbd_audio_rx_count + codec.getSampleCounter();
usbd_audio_rx_count = 0;
uint32_t pos = usbd_audio_rx_count + codec.getSampleCounter(); // problem: counting from codec block start
usbd_audio_rx_count = 0; // problem: next block will increment by a full blocksize
return pos;
}

Expand Down Expand Up @@ -252,21 +252,17 @@ void setButtonValue(uint8_t ch, uint8_t value){
if(ch < NOF_BUTTONS){
timestamps[ch] = getSampleCounter();
stateChanged.set(ch);
// if(value)
// button_values |= (1<<ch);
// else
// button_values &= ~(1<<ch);
}
button_values &= ~((!value)<<ch);
button_values |= (bool(value)<<ch);
}

// pre / post fx routing
#if defined USE_USBD_AUDIO_RX and !defined USE_USBD_AUDIO_RX_POST_FX
#define USE_USBD_AUDIO_RX_PRE_FX
#if defined USE_USBD_AUDIO_RX and !defined USE_USBD_AUDIO_RX_PRE_FX
#define USE_USBD_AUDIO_RX_POST_FX
#endif
#if defined USE_USBD_AUDIO_TX and !defined USE_USBD_AUDIO_TX_POST_FX
#define USE_USBD_AUDIO_TX_PRE_FX
#if defined USE_USBD_AUDIO_TX and !defined USE_USBD_AUDIO_TX_PRE_FX
#define USE_USBD_AUDIO_TX_POST_FX
#endif

/* called by the program when a block has been processed */
Expand Down
4 changes: 2 additions & 2 deletions XibecaDevKit/Core/Inc/hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
#define CODEC_BLOCKSIZE 256 // with bs=512 DMA_D2=64k overflows by 1580 bytes
#define AUDIO_BLOCK_SIZE 32

#define USE_USBD_AUDIO_RX_POST_FX
#define USE_USBD_AUDIO_TX_POST_FX
#define USE_USBD_AUDIO_RX_PRE_FX
#define USE_USBD_AUDIO_TX_PRE_FX

/* USB audio settings */
#define AUDIO_BITS_PER_SAMPLE 16
Expand Down

0 comments on commit 74de899

Please sign in to comment.