If we want to extend the sequencer of blender to a real audio sequencer solution some day this might again come very handy. (Thinking of the short audio snippets more of instrument samples...)
But most of the time I do video editing I work with longer audio tracks which have been created in a seperate audio editing system and only put it together in the blender sequencer. For this kind of longer audio timelines it is more favourable to keep these tracks on disk and only read them into memory on demand. (Think of several two hour audio track on the timeline...)
Since both ways of thinking of audio are sensible (it depends on the needs) both are still included in the sequencer. I used the naming of the commercial audio editing program "Samplitude" and distinguished the two calling the one "Audio (RAM)" and the other "Audio (HD)".
struct hdaudio * sound_open_hdaudio(char * name):
Open the audio file called "name" and return a hdaudio-struct on success. Anything which has an audio track in it can serve for this (especially DV-files). The current implementation uses ffmpeg to open audio files. It could be easily extended to other interfaces. It should especially additionally contain a fallback which at least works with WAV-files on any platform.
struct hdaudio * sound_copy_hdaudio(struct hdaudio * c):
Clone a hdaudio-struct. This is used by the duplicate-tool.
long sound_hdaudio_get_duration(struct hdaudio * hdaudio, int frame_rate):
Get the duration of the opened audio file in frames. You have to tell it the frame_rate. If you change the frame rate in the middle of your project, you most likely have to reload your "Audio (HD)" files. But if you think a little bit about this, you will notice that this is one of the smaller problems if you change your idea of a frame rate in the middle of the flight...
void sound_hdaudio_extract(struct hdaudio * hdaudio,
short * target_buffer,
int sample_position /* units of target_rate */,
int nb_samples /* in target */):
This extracts samples 16-bit signed from sample_position at target_rate and target_channels. Since hdaudio does not tell you anything about the sample rate of the underlying audio file you probably guessed, that we do rate conversion on the fly. target_buffer must provide at least room for nb_samples * target_channels * 2 bytes.
void sound_close_hdaudio(struct hdaudio * hdaudio):
Close the file again and free all internal structures.