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
jacqueline 690c64c151 Fix playback after restoring queue on boot 12 months 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 Count samples going in and out of the drain buffer 12 months ago
audio_decoder.hpp Count samples going in and out of the drain buffer 12 months ago
audio_events.hpp Count samples going in and out of the drain buffer 12 months ago
audio_fsm.cpp Fix playback after restoring queue on boot 12 months ago
audio_fsm.hpp Count samples going in and out of the drain buffer 12 months ago
audio_sink.hpp Count samples going in and out of the drain buffer 12 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 Count samples going in and out of the drain buffer 12 months ago
bt_audio_output.hpp Count samples going in and out of the drain buffer 12 months ago
fatfs_source.cpp move driver includes into a subdir as well 12 months ago
fatfs_source.hpp start moving include files into subdirs 12 months ago
fatfs_stream_factory.cpp Improve decoder's interface to accept streams 12 months ago
fatfs_stream_factory.hpp Improve decoder's interface to accept streams 12 months ago
i2s_audio_output.cpp Count samples going in and out of the drain buffer 12 months ago
i2s_audio_output.hpp Count samples going in and out of the drain buffer 12 months ago
processor.cpp Count samples going in and out of the drain buffer 12 months ago
processor.hpp Count samples going in and out of the drain buffer 12 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 start moving include files into subdirs 12 months ago
resample.hpp WIP merge cyclically dependent components into one big component 12 months ago
stream_cues.cpp Fix playback after restoring queue on boot 12 months ago
stream_cues.hpp Fix playback after restoring queue on boot 12 months ago
track_queue.cpp start moving include files into subdirs 12 months ago
track_queue.hpp start moving include files into subdirs 12 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