This website is out of date
PLEASE VISIT
THE NEW WEBSITE
critter board

Video and Sound with the Video Critter Hi-Res

This example demonstrates how to display some simple graphics on a TV using the video routines while also producing audio output. The example provides a good template for bigger projects.

Downloads:

  • Video and Sound example
  • Video and Sound example with precompiled video routines
  • Here is a video clip of the example:

    pcb pic

    Running the example

    After downloading the example code, unpack it, and in a terminal window run 'make' to compile the code. Then upload the resulting main.hex file to the Video Critter.

    The video routines, in the file video.c, are picky about compiler settings (such as optimization level), so there is a version of this example with those routines precompiled. If you want to get into lower level video programming, download the version thats not precompiled.

    About

    The main.c file contains the main application. It demonstrates some high level graphic functionality: drawing pixels, lines, circles, chracters, filling the screen with a constant color, and inverting the display. Then the program enters a loop to demonstrate how to make sound and video at the same time.

    The file graphics.c contains higher level graphic functions for drawing pixels and printing characters. Additional graphics functions can be based on the put_pixel function.

    The low level video synthesis happens in video.c. It runs using interrupts to trigger events in the video signal.

    Producing audio requires an audio buffer. At each new line event (around 15.7 kHz), the video routine outputs the next value from an audio buffer to the DAC. So the sampling rate is the same as the NTSC line rate.

    To produce sound, the function audio_fill_buf() in audio.c must be called every few milli-seconds. This function keeps the audio buffer filled by calculating sample values. Many audio algorithms may be used to calculate sound, in this tutorial we have a 4 voice triangle wave oscillator with adjustable frequency and amplitude.

    Check out the for(;;) loop in main.c to see one simple method for handling time events while also calling audio_fill_buf() quickly enough to avoid buffer overruns.