File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
ports/nrf/common-hal/audiobusio Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -167,11 +167,17 @@ stopping: ;
167
167
self -> sample_data += bytecount ;
168
168
bytesleft -= bytecount ;
169
169
}
170
+
171
+ // Find the last frame of real audio data and replicate its samples until
172
+ // you have 32 bits worth, which is the fundamental unit of nRF I2S DMA
170
173
if (self -> bytes_per_sample == 1 && self -> channel_count == 1 ) {
171
- self -> hold_value = 0x01010101 * * (uint8_t * )(buffer - 1 );
174
+ // For 8-bit mono, 4 copies of the final sample are required
175
+ self -> hold_value = 0x01010101 * * (uint8_t * )(buffer - 1 );
172
176
} else if (self -> bytes_per_sample == 2 && self -> channel_count == 2 ) {
177
+ // For 16-bit stereo, 1 copy of the final sample is required
173
178
self -> hold_value = * (uint32_t * )(buffer - 4 );
174
179
} else {
180
+ // For 8-bit stereo and 16-bit mono, 2 copies of the final sample are required
175
181
self -> hold_value = 0x00010001 * * (uint16_t * )(buffer - 2 );
176
182
}
177
183
}
You can’t perform that action at this time.
0 commit comments