Notes with pdf-presenter-console and latex beamer

I’m giving a talk soon and I thought it is a good idea to make the slides with latex beamer. Fair enough the slides were made quickly and everything was set.

After a while I found a good presentation tool named pdf-presenter-console which is written in Vala and just fits my needs, except for the lack of a method for displaying notes on your slides. It uses one screen displaying the current and the next slide as well as the elapsed time and the other screen for the current slide in full screen for the audience. What I wanted was, that the presenter screen, that is the one with the information for the presenter (me), displaying the slides with notes.

The code base of pdf-presenter-console allows a very quick change so that one can pass another PDF file to the presenter than to the presentation. Now what I needed was a way to include the notes in my slides.

As I found out, latex beamer supports notes but displays them on a separate slide using a more or less ugly theme. Using pgfpages and a simple .sty file I got a workaround for that. I created a new direction for the two screen pgf layout based on bottom and changed the dimension in a way that both pages overlap. In the .tex file I only had to use it and to make the notes template a bit more usable.



% Page layout which lays the second page over the first
\define@key{pgfpagesuselayoutoption}{second notes bottom}[]%

in the .tex file:


% Use slide with red box + notes for notes
\setbeamertemplate{note page}{
    \vspace{.9\textheight} % skip 90% of the page


% Itemize for notes with little spacing

% Enable this to have notes in your slides!
\setbeameroption{show notes on second screen=notes bottom}

Usage example:


            \item Foo
            \item Bar

pdf presenter console usage example:

$ pdf_presenter_console slides.pdf slides_notes.pdf

To use this, copy the .sty content in your texmf path and add the .tex file content to your tex file.

The necessary changes for pdf-presenter-console are available at my github repository (#d24056)

C/C++: Fill variables using a single value

A more or less interesting C/C++ problem occured to me this day:

How do I initialize an integer with one part without using shifts. For example you have 0xFF and you want 0xFFFFFF.

Normally you would do something like this

int x = 0xFF << 16 | 0xFF << 8 | 0xFF

But how does it work without this runtime computation? And does it help you increase your performance? Of course not, but we'll see.

One could use arrays:

#define FILL(x,t) *(t*)(const unsigned char[]){x,x,x,0}

int main() {
    int foo = FILL(0xFF, int);

    return 0;

This would convert to the following assembly (64bit code):

    subq    $16, %rsp       ! reserve space for rbp and foo
    movl    $._6, %eax      ! load address of ._6 (our static array)
    movl    (%rax), %eax    ! dereference rax and save value in eax
    movl    %eax, -4(%rbp)  ! save value of eax in `foo`

    .byte    -1
    .byte    -1
    .byte    -1
    .byte    0

If you're wondering why there is -1 and not 255 at the .byte directive, the number stands for 0b11111111 whereas -2 would stand for 0b11111110 and so on.

Comparsion to naive solution

The naive solution:

int foo = 0xFF << 16 | 0xFF << 8 | 0xFF

Compiles to the following assembly (64bit again):

    subq    $16, %rsp
    movl    $16777215, -4(%rbp)
    movl    -4(%rbp), %eax

The compiler optimizes the expression so it is a number which will be put into our variable foo. This is way better than loading an address and dereferencing it.


Use shifts, the compiler will optimize them anyway.

Using the kinect camera with Ubuntu Oneiric Ocelot

This post resembles the major problems (and solutions) which I had, using my previously working OpenNI/NITE setup on Ubuntu/amd64.

If you need to know how to setup your kinect camera, please take a look at this post. Of course, the guide if for previous Ubuntu versions but it worked for me quite well.

Kinect as HID

I noticed that I got a warning, that the USB device could not be initialized.

strace revealed, that the USB device was busy with something.

I remembered from projects before using USB, that the linux kernel happens to assign HID drivers to generic USB devices.

Exactly this was the problem.

The detach-tool from this website solved the problem for me:

$ sudo ./detach 045e 02ae

I got the Vendor/Product ID required from lsusb.

$ lsusb

Bus 002 Device 007: ID 045e:02ae Microsoft Corp. Xbox NUI Camera

Depth image not existant or garbled

This is a funny one. The depth image was not existant or looked like a pile of grey marshmellow clouds.

I got the final hint for this in this discussion.

The problem is that memcpy in the libc was modified to use SSE3 instructions on amd64, which leads sometimes to backwrites (as far as I understood).

The solution was to add


to /etc/ (the file didn’t exist until then).