UEFIStarter
a simple UEFI framework
|
AC'97 audio demo. More...
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/ShellCEntryLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <UEFIStarter/core.h>
#include <UEFIStarter/ac97.h>
#include <UEFIStarter/pci.h>
Macros | |
#define | SAMPLES_PER_BUFFER 10000 |
Number of samples to use in each buffer. More... | |
#define | SAMPLES_FREQ(FREQ) ((tc%(FREQ))*60000/(FREQ)-30000) |
Shortcut macro to sample a (non-harmonic) frequency. More... | |
Functions | |
void | fill_buffers_crossscale (ac97_buffers_s16_t *buffers, unsigned int start_buffer, unsigned int buffer_count, unsigned int loop_offset) |
Fills audio buffers with scales, one channel going down, the other channel going up. More... | |
void | fill_buffers_harmonic_scale (ac97_buffers_s16_t *buffers, unsigned int start_buffer, unsigned int buffer_count) |
Fills audio buffers with harmonic scales. More... | |
void | output_audio (ac97_handle_t *handle) |
Fills audio buffers with scales, copies buffers to AC'97 device and starts playback. More... | |
void | loop_civ (ac97_handle_t *handle) |
This fills audio buffers while they're being played. More... | |
EFI_STATUS | run_audio_stuff (EFI_PCI_IO_PROTOCOL *audio) |
Handles entire lifetime of AC'97 audio output. More... | |
INTN EFIAPI | ShellAppMain (UINTN argc, CHAR16 **argv) |
Main function, gets invoked by UEFI shell. More... | |
AC'97 audio demo.
#define SAMPLES_PER_BUFFER 10000 |
Number of samples to use in each buffer.
Determines length of individual notes (thus speed of playback). Keep this value below 32767.
#define SAMPLES_FREQ | ( | FREQ | ) | ((tc%(FREQ))*60000/(FREQ)-30000) |
Shortcut macro to sample a (non-harmonic) frequency.
FREQ | the frequency to use (of no particular unit) |
void fill_buffers_crossscale | ( | ac97_buffers_s16_t * | buffers, |
unsigned int | start_buffer, | ||
unsigned int | buffer_count, | ||
unsigned int | loop_offset | ||
) |
Fills audio buffers with scales, one channel going down, the other channel going up.
Does not use the harmonic scale: this will sound bad.
buffers | the AC'97 buffer list to fill |
start_buffer | index of the first buffer to fill |
buffer_count | the number of buffers to fill |
loop_offset | offset for loop counter, the higher this is the higher the generated notes will be |
void fill_buffers_harmonic_scale | ( | ac97_buffers_s16_t * | buffers, |
unsigned int | start_buffer, | ||
unsigned int | buffer_count | ||
) |
Fills audio buffers with harmonic scales.
buffers | the audio buffers to write to |
start_buffer | index of the first buffer to fill |
buffer_count | number of buffers to fill |
void output_audio | ( | ac97_handle_t * | handle | ) |
Fills audio buffers with scales, copies buffers to AC'97 device and starts playback.
This is pretty much how you'd output prepared audio, e.g. when playing music.
Start the application with -trace
to see when playback switches to the next buffer.
handle | the AC'97 handle to use |
void loop_civ | ( | ac97_handle_t * | handle | ) |
This fills audio buffers while they're being played.
This is how you'd output audio on the fly, e.g. sound effects that depend on user inputs.
Seems like the timer granularity can't be decreased much, setting it to e.g. 5ms loses count of a few ticks.
handle | the AC'97 handle to use |
EFI_STATUS run_audio_stuff | ( | EFI_PCI_IO_PROTOCOL * | audio | ) |
Handles entire lifetime of AC'97 audio output.
This shows the high-level interface to the AC'97 library: find the audio device, initialize the handle, configure audio output, fill buffers, start playback and finally close the handle.
audio | the UEFI PCI I/O protocol for the AC'97 chipset |
INTN EFIAPI ShellAppMain | ( | UINTN | argc, |
CHAR16 ** | argv | ||
) |
Main function, gets invoked by UEFI shell.
argc | the number of command-line arguments passed |
argv | the command-line arguments passed |