-
Notifications
You must be signed in to change notification settings - Fork 4
Get started with the demos
By following these instructions you will be able to run the two demos VoxBox and RVC. The first one is an audio signal processing application called VoxBox, which implements a vocoder application. The other demo RVC is a video decoder from the ISO/MPEG standard called Reconfigurable Video Coding. So when running these demo you will either hear something or see something. Both these two demos are dataflow applications. To run the demos you need a Linux installation, with Java, and Eclipse. The Eclipse must have three plugins installed: Xtext, C/C++ development tools, and Caltoopia. A detailed installation instruction is found here. So let's get started.
-
First you need to get the source code for the demos:
git clone https://github.com/Caltoopia/caltoopia-demo-apps.git
2. Start Eclipse and import the demo-apps projects in Eclipse. Select "Import" from the "File" menu and chose "General"->"Existing Project into Workspace".
Then import all the demo apps:
And then you will see at least three projects: RVC, VoxBox, and System. The last one contains utility functions, external functions and external actors (i.e. native actors and functions provided by the runtime environment).
-
Time to configure Caltoopia and you need to point out where you have located the Caltoopia-linux-runtime during the Installation. You reach the settings by "Window"->"Preferences"->"Caltoopia". Only the runtime installation is necessary at this point (the rest is for more experimental features used by some daring Caltoopia ninjas).
-
Now it is time to take a look at the video decoder demo "RVC". We start by selecting "Run"->"Run Configurations" and creating a new Caltoopia configuration. Here we need to select
- The project -> "RVC"
- The top level network, which is the entry point of the program. You can think of it as the "main" function/method in C and Java programs. A top level network in Caltoopia is a CAL network that has no input or output ports and no parameters. From the list of possible top level networks you select "decoderDemo", which is a network that reads a bitstream from a file and shows it on the screen using a display actor. The actors for reading data from file and displaying the video are so called system actors, which are implemented in C and whose interface is defined in the "System.ART"-project.
- The "Output Folder" is where the generated C-code will be located. Just pick any location on your file system that you find suitable.
- The "Working Folder" is where the resulting binary will be executed. For example, this means that all relative paths will be relative to this folder. In the case of the RVC demo we are reading a bit file containing the video ("foreman_qcif_30.bit"), which is located in the same directory as the source code. So here you enter the location of the demo source code for the "caltoopia-demo-apps/RVC_MPEG4_SP_Decoder".
- Select "Create CDT Project", which will create a C-project called "RVC-gen" from the generated C-code.
- Also select "Show Graph" which will visually display the flattened network as part of the compilation.
- Debug should usually be set to "None" to not generate any debug output.
-
Klick "Apply" and the "Run". Now the Caltoopia compiler will first generate C-code into the specified output directory. Since, you have clicked in the "Show Graph", the flattened network is shown once the C code generator is done. All actors are coloured with respect to their dataflow characteristics, but for now we can just ignore that and enjoy the picture. To run the video, now press "Run" and you should see the video like this:
-
Now, we are ready for the second demo "VoxBox". So again, open up the "Run"->"Run Configurations" and configure one for "VoxBox" like this:
And this is basically the procedure as for the "RVC"-demo. Note: By leaving the "Working folder" field empty, the binary is executed from the "Output folder".
-
Press "Run" and now the C-code is generated and a C-project named "VoxBox-gen" is created. Oops, now run into a small problem! The C compiler is complaining that "No rule to make target 'speaker.c'". This is the build systems way of saying that it is missing the file 'speaker.c'
So why does this happen? To figure this out, we can take a look at the CAL source code for the actor 'Speaker.cal'. That actor takes an array of audio elements and outputs them on the speaker. To this it relies on two external functions implemented in C
external function openAudioOutput(int channels, int sampleRate, int bitsPerSample) --\> int;
external procedure audioOutput(int fd, float[10] x, int size);
These functions are available in the file 'speaker.c', which is also found in the VoxBox directory and the annotation in the 'Speaker.cal'
@extern(c\_sources="speaker.c")
This annotation instructs the build system to look for the file 'speaker.c'. To fix the compilation problem we need to copy this file to the directory were we chose to place the generated (in my case that path is '/home/johan/dev/caltoopia-output/VoxBox'). So, let's open a terminal window and
- first make a 'cd' to the output directory
- copy the file 'speaker.c'
- Run 'make'
Alternatively in the file 'Speaker.cal' we can change the line to:
@extern(c\_sources="\$PROJECTROOT/speaker.c")
This will tell the compiler to look for the speaker.c file in the CAL-project folder. -
Now we should have a binary that has the same name as the top level actor. In our case it is "Demo2b_Robot". Let's try to run it by typing "./Demo2b_Robot". Did you hear a sound? Then all is good and you have graduated from the CAL tutorials. If not you may be missing a input wav file, copy one to the Output folder (when standing in that folder):
cp <path>/caltoopia-demo-apps/VoxBox/test/wav-input/cal-is-the-way-of-the-future.wav ./in.wav
8b. If not, chances are that you have run into problems with Linux audio system. Some user get an error message saying that '/dev/dsp' cannot be found or opened (or just silence, no errors in case of running e.g. Ubuntu 13.04), which is caused by our choice of a dated audio subsystem. The good things is that this is easily fixed by using the Pulse Audio helper program 'padsp', which simulates the '/dev/dsp' device. It is used like this: "padsp ./Demo2b_Robot". Note that if you press the run button in the showed graph window the padsp will not be used. Done