Fork of Tangara with customizations
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
tangara-fw/src/tangara/audio
Ondřej Hruška 0e18330233 Adjust bluetooth volume change speed to more usable 6 days ago
..
test WIP merge cyclically dependent components into one big component 12 months ago
README.md WIP merge cyclically dependent components into one big component 12 months ago
audio_decoder.cpp Add bitrate info 3 months ago
audio_decoder.hpp Timeout when writing output samples throughout the audio pipeline 8 months ago
audio_events.hpp Allow manually unmounting the SD card 2 months ago
audio_fsm.cpp fix premature pause at end of last track of queue 1 week ago
audio_fsm.hpp Allow manually unmounting the SD card 2 months ago
audio_sink.hpp Introduce a PcmBuffer abstraction for handling source draining 11 months ago
audio_source.cpp start moving include files into subdirs 12 months ago
audio_source.hpp start moving include files into subdirs 12 months ago
bt_audio_output.cpp Adjust bluetooth volume change speed to more usable 6 days ago
bt_audio_output.hpp Give PcmBuffer pairs a name, and wire them up in the audio stack 10 months ago
fatfs_source.cpp no more acquire_spi :) 11 months ago
fatfs_source.hpp start moving include files into subdirs 12 months ago
fatfs_stream_factory.cpp Add WavPack support 1 month ago
fatfs_stream_factory.hpp Break FatfsStreamFactory's dep on ServiceLocator 9 months ago
i2s_audio_output.cpp Changed volume to go in 5pct steps 6 days ago
i2s_audio_output.hpp Give PcmBuffer pairs a name, and wire them up in the audio stack 10 months ago
playlist.cpp Don't create a cache file on deserialising 7 months ago
playlist.hpp Explicitly close the playlist files in the queue on storage unmount 7 months ago
processor.cpp Play TTS files in response to TTS prompts, but it's legible now 7 months ago
processor.hpp Play TTS files in response to TTS prompts, but it's legible now 7 months ago
readahead_source.cpp move driver includes into a subdir as well 12 months ago
readahead_source.hpp start moving include files into subdirs 12 months ago
resample.cpp Timeout when writing output samples throughout the audio pipeline 8 months ago
resample.hpp Timeout when writing output samples throughout the audio pipeline 8 months ago
sine_source.cpp Add a stream source that generates a sine wave 11 months ago
sine_source.hpp Add a stream source that generates a sine wave 11 months ago
stream_cues.cpp fix premature pause at end of last track of queue 1 week ago
stream_cues.hpp fix premature pause at end of last track of queue 1 week ago
track_queue.cpp Fix playlists not setting the queue to ready 3 months ago
track_queue.hpp Improvements to the queue for shuffling/playing all (#170) 3 months ago

README.md

/*

FatfsAudioReader

  • input if a queue of filenames.
  • output is a cbor stream
    • 1 header, like "this is a new file! this is the file type!
    • followed by length-prefixed chunks of bytes
  • runs in a task, which prompts it to read/write one chunk, then returns.
  • task watches for kill signal, owns storage, etc.

AudioDecoder

  • input is the chunked bytes above.
  • output is also a cbor stream
    • 1 header, which is like a reconfiguration packet thing.
    • "data that follows is this depth, this sample rate"
    • also indicates whether the configuration is 'sudden' for soft muting?
    • then length-prefixed chunks of bytes

AudioOutput

  • input is the output of the decoder
  • outputs via writing to i2s_write, which copies data to a dma buffer
  • therefore, safe for us to consume any kind of reconfiguration here.
    • only issue is that we will need to wait for the dma buffers to drain before we can reconfigure the driver. (i2s_zero_dma_buffer)
  • this is important for i2s speed; we should avoid extra copy steps for the raw
  • pcm stream
  • input therefore needs to be two channels: one configuration channel, one bytes channel

How do things like seeking, and progress work?

  • Reader knows where we are in terms of file size and position
  • Decoder knows sample rate, frames, etc. for knowing how that maps into
  • the time progress
  • Output knows where we are as well in a sense, but only in terms of the PCM output. this doesn't correspond to anything very well.

So, to seek:

  • come up with your position. this is likely "where we are plus 10", or a specific timecode. the decoder has what we need for the byte position of this
  • tell the reader "hey we need to be in this file at this byte position
  • reader clears its own output buffer (since it's been doing readahead) and starts again at the given location For current position, the decoder will need to track where in the file it's up to.

HEADERS + DATA:

  • cbor seems sensible for headers. allocate a little working buffer, encode the data, then send it out on the ringbuffer.
  • the data itself is harder, since tinycbor doesn't support writing chunked indefinite length stuff. this is a problem bc we need to give cbor the buffer up front, but we don't know exactly how long things will be, so it ends up being slightly awkward and inefficient.
  • we could also just like... write the struct i guess? that might be okay.
  • gives us a format like
  • could be smart with the type, use like a 32 bit int, and encode the length
  • in there?
  • then from the reader's perspective, it's:
    • read 4 bytes, work out what's next
    • read the next X bytes