Friday, December 4, 2015

How to watch paid videos on Youtube/Google Play on Debian Linux with DRM

In order to watch paid videos from youtube/google play on Debian/Firefox, you need the latest flash plugin.  To to get this, run

sudo apt-get install flashplugin-nonfree

If you already have flashplugin-nonfree installed, you should run

update-flashplugin-nonfree --install

You can then run

update-flashplugin-nonfree --status

to verify that you have the latest version. Once you have the latest flash version, you need to install HAL for the flash DRM playback to work.  Unfortunately, HAL is deprecated, so you have two options: First is to install zombie hal which is a version of hal that has been kept alive for purposes of DRM support.  Unfortunately, zombie hal is for ubuntu, and my attempts to use it on debian didn't work.  The second option is hal-flash  which is a fake version of hal designed to be just functional enough that flash will accept it.  In order to install on debian, just download the source code, and run dpkg-buildpackage from the source directory. It will tell you any required packages you need to install, and when it finishes running, it will produce a .deb file in the parent directory, which you can install directly.

After installing hal-flash, I cleared the adobe cache which is suggested by many instructions online by deleting the .adobe directory.

At this point, I was still getting the message "an error occurred. please try again later".  To investigate, I used the rightclick -> copy debug info.  On inspection of this info, it looked to be url encoded, so I used an online url decoder to inspect the contents.  The key part of the decoded info was the section "debug_error=[ErrorEvent type="FlashAccess:3315:0" bubbles=false cancelable=false eventPhase=2 text=""]".  To investigate this further, I opened firebug, and looked at the net panel, to see the network activity taking place.  It turned out that the request to youtube.com/crossdomain.xml was never completing, and I eventually figured out that this was due to the plugin HTTPS everywhere I had installed.

After disabling HTTPS everywhere, it began to work on one computer, but on the other computer, the same steps still left it broken, giving me an error message "There is an error with your flash player. Click here, select reset license files, and restart your browser".  The debug info showed me that this is caused by error "FlashAccess:3329:500".  This indicates according to the flash reference that it is some sort of "application specific error", meaning I'd need google/youtube's help debugging it further, which they don't offer.  My own investigation of the network traffic just seems to indicate that nothing is going obviously wrong.

Hopefully these steps are useful to you!

Monday, March 2, 2015

Notes on implementing neural networks


Here are some notes on implementing deep neural networks.

Visualize as much as possible

No, I don't mean in the sense of simply imagining success, but in the sense of creating visual representations of your models and the training process.  When you write the code to do the training and run it, it can be hard to diagnose what's going on when it just prints out "ERROR RATE" at every iteration.  Even just graphing the error rate can help you tell if things are converging or diverging easier than printing it out in textual format.

Of course this is much more useful if you are learning a visual task, but be creative, and use tools like T-SNE  to visualize data that isn't directly visual.  It will end up being a lot of effort to do visualization, even more than the actual implementation, but it's worth it in the end.

Use automatic differentiation

The common advice I see on training neural networks is to always check whether your gradient code is correct by using the finite differences method.  I would go further and say that it is worthwhile to use automatic differentiation if possible.  You get precise answers as to what the gradient /should/ be, and when you write the optimized  implementation of the gradient calculation, you can compare the results side-by side.  If you don't care about speed, you can just run the whole algorithm using the Automatically differentiated gradient and not worry about writing any extra code at all.


Tuesday, June 3, 2014

How to build an LLVM pass using SCons

LLVM provides some nice documentation on how to build a simple pass using CMake, but if you want to build your project using SCons, this is not very useful. 

Luckily, there is an easy configuration tool "llvm-config" which gives you all the information you need to build against llvm.  Simply add the line
env=Environment()
env.ParseConfig("llvm-config-3.5 --cppflags --cxxflags")
to your SConstruct file, and it should handle all of the llvm compiler flags for you.

Sunday, April 6, 2014

Building mlpack .deb

mlpack is a nice C++ library for machine learning, but unfortunately it doesn't have widely available Debian packages.  A few years ago someone made packaging, but his attempts to get it included in Debian is sadly documented here.  I wasn't able to find ready-built packages for Debian, and the build instructions on the mlpack website don't tell you how to build a deb.  Luckily, I did some snooping around and figured out how to do it.


First, download the latest tarball, and save it in a folder named "tarballs".  We then want to check out an svn directory (in the same folder the contains the tarballs folder).

Run 

$svn co http://svn.cc.gatech.edu/fastlab/mlpack/conf/packages/mlpack/trunk mlpack
 
Now make sure you have svn-buildpackage installed, along with all the other mlpack dependencies.


There is a bug in  the packaging, in that the default make target does not build the documentation, but the package tries to install it anyway, causing the package to fail to build.  I also found that the 1.08 version test suite fails, also halting the build, so I disabled it.

To fix these things, enter the mlpack directory you just checked out and edit debian/rules .  At the bottom of the file, modify it so it looks like


%:
        dh $@

override_dh_auto_build:
        dh_auto_build
        dh_auto_build -B -Smakefile -- doc

override_dh_auto_test:

Finally, from the mlpack directory run

$sh debian/build-from-svn.sh
 
This still might not work... I'll update this later 

Monday, December 9, 2013

Student StarCraft AI Tournament Tutorial for Getting Started with C++

The Student Starcraft AI tournament is an ongoing competition to write a bot to compete in playing 1v1 games of the real-time strategy game Starcraft. I found the documentation on how to get started to be scattered and lacking, and I hope to consolidate the knowledge I gained here into a mini-tutorial that will lower the barrier for entry.

PART 1 - Running the Example AI

First, you will need Starcraft Brood War patched to version 1.16.1 installed (You do not need the CD to run the game if you follow the instructions in the patch notes for version 1.15.2).

Next, you will need to download and extract BWAPI version 3.7.4 which is  not the latest version, however it is the version used by the SSCAI tournament.  I found that the included installer does not work, as confirmed by bug reports which were addressed in later versions.  However, later versions do not help us, as we need version 3.7.4 for the tournament.  Once extracted, the readme says

2. Run "install.exe". This will do the following:
    * Copies the contents of ./WINDOWS/ to the C:/Windows folder.
    * Copies the contents of ./Starcraft/ to your actual Starcraft folder.
    * Performs additional minor installation steps.
so, assuming the "additional minor installation steps" are nothing of importance, we can manually install BWAPI by copying the files according to the above instructions.  (This is what I did, and everything seems to have worked for me).

Next, you  need to install Visual Studio 2008 (the version is important, as later versions will give you errors when you try to compile).  You don't need to buy the full version, as Visual C++ 2008 Express Edition works fine, and is freely available for download.

When Visual Studio is installed, we will try using it to compile the example project and test it.  To do so, open up ExampleProjects.sln from the root directory of BWAPI in Visual Studio, and select Build>Build Solution from the menu bar.  When this is completed, check the output tab at the bottom for build errors (there should be none, if there are any errors, good luck!) .

To run the example AI module

1. Copy Release/ExampleAIModule.dll to
   <starcraft folder>/bwapi-data/AI/ExampleAIModule.dll

2. Open <starcraft folder>/bwapi-data/bwapi.ini and set ai to
   bwapi-data/AI/ExampleAIModule.dll if it isn't already.
 
3. Run Chaoslauncher with BWAPI Injector checked. You can also check W-MODE
   to have Broodwar run in a window rather than full-screen.
For the second step, this simply means editting the line in bwapi.ini which starts with
ai     =
to say
ai     =  bwapi-data/AI/ExampleAIModule.dll
You can also choose to build the debug version in Visual Studio.  In that case, you would copy the dll from Debug/ExampleAIModule.dll and modify the line starting with ai_dbg instead.  When starting up starcraft, you will have an option to choose between running debug mode or not, and the AI from the appropriate DLL will be loaded.  Nothing else in the bwapi.ini file needs to be edited for now.

Chaoslauncher can be found in the BWAPI main directory under Chaoslauncher/Chaoslauncher.exe.  When you open it, you can see the choice of checking off the BWAPI DEBUG or RELEASE options.  Check off just one, and optionally W-MODE (I suggest using debug mode and W-MODE), and click start.  You can safely ignore a warning about admin privileges if it pops up.  From here, you just need to get into a Starcraft game, and BWAPI should take over with the example AI.  The quickest way is to select a single-player expansion custom game and start the game.  The Example AI module should print some debug text to the screen and issue some basic commands to your probe and command center. If this happens, you have successfully completed the first step on getting your own BWAPI bot to run.

PART 2 - Creating your own AI Project


Wednesday, November 7, 2012

Installing Steam Linux Beta on 64 bit Debian

Valve recently came out with a closed beta for Steam on Linux.  For the initial beta, they are only supporting Ubuntu.   Luckily, people on reddit and other places have found workarounds to install the beta client if you're not part of the beta, and on other distros besides Ubuntu.  On amd64 Debian, there's the additional problem that the client is only 32 bit.

Anyone can download the .deb that valve released at http://media.steampowered.com/client/installer/steam.deb. unfortunately for us this is a 32-bit Ubuntu package, and it isn't even a clean deb file: it will try to install additional dependencies when you run it for the first time.  We basically want to ignore any dependency fetching it does and manually install all the dependencies on our own.

First, we just want to force the install of a 32-bit package on the wrong architecture.  To do this we run
$sudo dpkg --force-architecture -i steam.deb
 from the terminal.  It will probably complain about dependencies;  ignore this.  We can't install all the required libraries through the debian package system, so instead we create a folder in your home directory to contain the alternate versions of these libraries.  Luckily steam user cyb.org has put together a script which installs all the required libraries.  The script can be found at http://dl.dropbox.com/u/29081229/Steam/debian_install.sh. The full contents of the script are
#!/bin/sh
STEAMLIBS=${HOME}/Steamlibc/
mkdir -p ${STEAMLIBS}
cd /tmp/
wget http://security.ubuntu.com/ubuntu/pool/main/e/eglibc/libc6_2.15-0ubuntu10.2_i386.deb
dpkg -x libc6_2.15-0ubuntu10.2_i386.deb /tmp/libc/
mv /tmp/libc/lib/i386-linux-gnu/* ${STEAMLIBS}
wget http://mirror.ovh.net/ubuntu//pool/main/j/jockey/jockey-common_0.9.7-0ubuntu7_all.deb
wget http://mirror.ovh.net/ubuntu//pool/main/x/x-kit/python-xkit_0.4.2.3build1_all.deb
sudo dpkg -i jockey-common_0.9.7-0ubuntu7_all.deb python-xkit_0.4.2.3build1_all.deb
sudo apt-get install libjpeg8 libcurl3-gnutls libtheora0 libpulse0 libpixman-1-0 libcairo2 libgdk-pixbuf2.0-0 libgtk2.0-0 libpango1.0-0
 in case that link changes its contents (maliciously or otherwise).  However, because a required library for steam is installed in your home directory, you need to launch the steam client with a special command line option.  cyb.org provides the script http://dl.dropbox.com/u/29081229/Steam/debian_steam.sh
#!/bin/sh
STEAMLIBS=${HOME}/Steamlibc/
LD_LIBRARY_PATH=${STEAMLIBS} /usr/bin/steam $@
to launch steam (the $@ is my addition so that it passes through arguments to the steam script). run
$chmod +x steam_debian.sh
to make it executable.  At this point, running the script may launch steam for you. Running
$./debian_steam.sh steam://open/games
 supposedly bypasses the beta check.  For me it popped open a dialog to download an update for steam, but after steam is updated, it won't do anything else.  You can easily run it under a debugger like so:

$DEBUGGER=gdb ./debian_steam.sh
For me doing so revealed that it was quitting with an exit code 0377 (which is equivalent to error code -1).

Saturday, January 28, 2012

FFMpeg Dnxhd: Could not write header for output file #0

Doing some video editing on linux, I wanted to convert the videos to a format easy to edit (and deinterlaced). I found this blog post: http://www.itc4u.net/it-chalk-board/67-linux-app-ffmpeg/115-edit-avchd-files-mts-with-blender-or-cinelerraconvert-mts-to-dnxhd-mov.html

Which seemed great, except when I ran the command he gave, I got the error "Could not write header for output file #0". (Stream 0 being the video stream). A bit cryptic. I eventually managed to figure out that this is due to the container format. Specifically, I was trying to encode it into an AVI. Apparently the Dnxhd encoder doesn't like this. If you encode it to a .mov, it works perfectly.

Saturday, August 6, 2011

Project Schliemann/ GLF/ Generic Language Framework with Netbeans

I've been trying for some time to get editing support in Netbeans for my custom language. There are many different APIs for doing this, depending on the version of Netbeans and the level of integration you want. Unfortunately, for my purposes there was only one API which was not ridiculously over-complex, called Project Schliemann (or alternately ".nbs files", or the "Generic Languages Framework"). The basic idea is that you write a single file with the grammar and rules about your language, and a generic parser reads that file and then can do some basic syntax checking, etc. on your code. Unfortunately, with recent versions of Netbeans, it has been removed. In addition, with version 6.0, I encountered a bug which prevented me from using it. This bug is fixed in 6.1, which is the version I ended up using.

After many tutorials and searching online, as well as several attempts for me to write or copy an NBS file, I still had made no progress. As a last ditch effort, I decided to try to find a complete working GLF Netbeans Project, to see if perhaps the entire API was broken. I discovered a Prolog Language support module, written by Rosa Gutierrez, on this page: http://edu.netbeans.org/courses/nbplatform-certified-training/linz.html unfortunately, the link to the source was dead! So I emailed her, and she was able to send me a copy of the source, which you can now download here.

Once I had a working module, I was able to incrementally modify it to do what I wanted. However, there is one catch which I didn't notice anywhere else: Even if your grammar would accept the contents of a file, if there is something in your file which is not defined as one of the tokens, then it will give you an error, even if that exact token is listed in your grammar as acceptable. That's a little confusing, but the basic idea is that even if your grammar defines

Statement = "Hello" | "Goodbye";

if "hello" and "goodbye" do not somehow fall under the category of one of the tokens you defined, you will get an error.

Also, another quirk of the grammar is that the "root" of the grammar must be labeled "S". So for example, a simple grammar might be entirely defined like

S = "hello world" | "goodbye world";

I'll post any more quirks or tips I encounter here.

Sunday, June 19, 2011

Fixing bad voices produced with festvox (or "Hey! My voice don't work!") (or "How to fix bad labellings")

Someone asked on a mailing list for possible ways to fix a bad voice the produced using festvox. I realized that my answer took my quite some time to figure out without any help, So I thought I'd post my response here.

Basically, if your voice is bad, chances are your labeling of some of the prompts is bad. (even if it isn't, it doesn't hurt to make sure they are good). You want to fix the bad labellings

To do so, copy the contents of your wav folder and the contents of your lab folder into the same directory (or setup links to make it seem that way). Once you've done that, open up the wav files with waveurfer, and choose the "transcription" view for all of them. Now you can go through one by one and check if the labellings are right. Options are: re-record the ones with bad labellings (remember to run bin/make_lab again before checking the labels again, I made this mistake once, and kept re-recording and thinking that the autolabeller sucked. Also, to save time, you can run bin/make_labs prompt-wav/test001.wav to just relabel test001.wav, instead of doing it to all the recordings, which can be time-consuming.), or hand-correcting the labels. You can literally just drag the labels from within wavesurfer (remember to copy your changes back to the lab/ directory).

Once you've got all the labels as perfect as you care to have them, just repeat all the steps after "bin/make_labs prompt-wav/*.wav" from whatever tutorial you are following and you should get the voice built with proper labeling (Come on, I know that if you knew how to do anything with festvox without a tutorial in front of you, there's no way you would need to be reading this post).

Thursday, June 9, 2011

Switching between multiple grammars with pocketsphinx

I was having difficulty understanding the pocketsphinx api, specifically when it comes to switching between multiple grammars.

Here's how it works:

Pocketsphinx actually keeps track of a set of grammars at all time. Normally, this set of grammars only has one element. However, it can contain multiple grammars, while only one is switched on at a time. The basic method is

  1. get this set of grammars using ps_get_fsgset()
  2. Add your grammar to the set using fsg_set_add()
  3. Select your grammar from the set as the active one using fsg_set_select()
  4. Notify the recognizer that you have updated the grammar using ps_update_fsgset()
(this assumes that the recognizer was initially instantiated with a FSG, rather than an N-Gram model. Otherwise, you first need to switch it to an FSG model).

Example code:

ps_decoder_t * p= ...; //Decoder already initialized somehow
fsg_model_t * m= ...; //Load the model using fsg_model_read or jsgf_parse_file and jsgf_build_fsg
fsg_set_t* fsgset=ps_get_fsgset(p);
fsg_set_add(fsgset, "newgrammarname", m);
fsg_set_select(fsgset,"newgrammarname")
ps_update_fsgset(p);

NOTE: I realize that even jsgf_build_fsg is confusing. Here's how you should handle it:

jsgf_build_fsg(jsfgmodel, rule, ps_get_logmath(ps), 6.5);

where jsfgmodel is the jsgf model loaded using jsgf_parse_file, and "rule" is a rule chose from it. (use the jsgf_* functions to select the rule). Also, free the jsgf once the fsg has been created using jsgf_grammar_free.

Oh yeah, and the 6.5 just seems to be a magic number. In two places I've seen it used without any explanation. The documentation says nothing about what the number "lw" does anywhere, so I'd just stick to the value 6.5 and hope for the best...

Friday, March 4, 2011

Pointyclicky for festival/festvox

There are references scattered throughout the festvox documentation to a GUI program for recording speech prompts, called "pointyclicky". Sounds nice, right?


Well, if you try to find the sources, you find that it was last updated in 2000 (!), and it's in disrepair. (http://festvox.org/pointyclicky/)

It won't compile any more, but Kev 'Kyrian' Green at the redhat bugzilla patched it up so it's closer to compiling. I also made some more changes so it would work for me on Debian, but I don't remember exactly what I did. Anyway, you can download my patched version of the sources from here, which should be up at least for the next four years.

Tuesday, February 8, 2011

Building (Open) AstroMenace on Debian

To start, download the sources from http://sourceforge.net/projects/openastromenace/, install the required dependencies (ReadMe.txt will tell you, or you can try just building it and see what it complains about missing), and build (cd build; cmake ..; make;).

While trying to build (Open) AstroMenace on Debian I encountered the following error:


OpenAstroMenaceSVN/AstroMenaceSource/Core/RendererInterface/OGL_Draw3D.cpp:38: error: ‘PFNGLCLIENTACTIVETEXTUREPROC’ does not name a type

Googling only turned up this, which was exactly the problem I encountered, but offered no solution.  I figured out it was missing a definition from some OpenGL header.  So I traced back the includes, and found the following text in OpenAstroMenaceSVN/AstroMenaceSource/Core/Base.h
#ifdef WIN32
        ...
#endif
#if defined(__APPLE__) && defined(__MACH__)
       ...
#else
        #define __glext_h_  // Don't let gl.h include glext.h
        #include      // Header File For The OpenGL32 Library
        #include     // Header File For The GLu32 Library
        #undef __glext_h_
#endif

Now, it has the comment "Don't let gl.h include glext.h".  However, I don't see why not!  Because when I comment out the #define and #undef statements, it compiles fine!  It should look like:

#else
        //#define __glext_h_  // Don't let gl.h include glext.h
        #include      // Header File For The OpenGL32 Library
        #include     // Header File For The GLu32 Library
        //#undef __glext_h_
#endif

So then it compiled correctly, but still got a very strange error when linking:

Linking CXX executable AstroMenace
c++: `sdl-config: No such file or directory
make[2]: *** [AstroMenace] Error 1
make[1]: *** [CMakeFiles/AstroMenace.dir/all] Error 2
make: *** [all] Error 2

It seems like some sort of quotation mismatch error.  I went through the CMake setup file, and it seemed fine. So instead, I just tried to manually link it myself.  I found the linker command it was trying to execute in CMakeFiles/AstroMenace.dir/link.txt, but I couldn't find anything wrong with it, so I copied the contents, put them into a terminal, and pressed enter. For some reason, this now worked!  For reference, this is what the file contained for me: http://pastebin.com/U8UifLAq

Once it built, I then went to download the necessary data files (under the vfs section of openastromenace downloads on sourceforge, download the data, and a language), and extracted their contents into the build directory.

Then run ./AstroMenace and .... well...it works for me at this point!

Sunday, February 6, 2011

Creating a voice with Festvox for Festival in debian/linux

Okay, Debian provides packages for speech-tools, but they aren't complete.  On top of that, the latest package versions provided at festvox.org are of incompatible versions with eachother.  Instead of trying to figure that out, I suggest downloading the svn: http://developer.berlios.de/svn/?group_id=3272

All we care about are speech_tools and

./configure and make them both.

Then start following this tutorial:

However, there might be a few problems.  Recording audio is a little bit funky, as they use na_record, which doesn't support ALSA.  However, hopefully you have oss support enabled.  When you get to the point where you are going to execute bin/prompt_them you might want to modify it first.

the line 

$ESTDIR/bin/na_record -f 16000 -t $duration  wav/$f.wav

can be replaced with

$ESTDIR/bin/na_record -audiodevice /dev/dsp1 -f 16000 -time $duration  wav/$f.wav
if you want to send it to the oss device /dev/dsp1

Or, you can replace it with arecord (which uses ALSA) like so:

arecord -Dplughw:1 -r 16000 -d $duration  wav/$f.wav

(this will record from the ALSA device plughw:1).

You can also uncomment various features inside this file, such as waiting for you to press return before recording, or playing back your recording immediately after you record it.

I'll update this as I encounter more problems.

Friday, January 14, 2011

Merging in git while ignoring newlines (or, Convert newline style to match file-by-file)

Basically, I want to merge two commits that are mostly the same, except some of the files have different newline endings.
Basically my problem looked like this.
      
     First commit with strange line endings
       | |
       V
A-B-C-D-E-F-G

        H
        ^
        ||
   Second commit with strange line endings.

I wanted to rebase H on top of C, and then merge with G. but C and H had differing newline endings, and there was no order to which files had which type.  So my solution was to hack together an absolutely horrible script that went through each file in H and converted it to UNIX or DOS newline styles, depending on which one would cause it to have a smaller diff with the same file in C.


Here it is:

    find . \! -type d -exec sh -c "unix2dos -q '{}';DOS=\$(git diff COMMITC -- '{}' | wc -c); dos2unix -q '{}'; UNIX=\$(git diff COMMITC -- '{}' |wc -c); if \[ \$DOS -lt \$UNIX ]; then unix2dos '{}'; fi" \;

You execute it with commit H checked out, and COMMITC replaced with the name of your "commit C" in my diagram.

Friday, December 17, 2010

Building Hypermammut in Debian.

So, I've been trying to get hypermammut to compile and run for me.  The released tarball has a few problems in it.  I've gotten it to compile, but it still crashes when I try to open a file.  However, I figure the steps I've shown are at least closer to getting it to work.

I should note that I am on a 64 bit system, but I think I will explicitly point out everywhere where this is relevant.

First of all, you need to install the proper dev files.  Obviously you need a C++ compiler, etc, but the libraries you need to install specially are (and I list them with their Debian package names): magick++-dev libfftw3-dev
libwxgtk2.8-dev libaudiofile-dev.  You also need to install the build tool scons.  I should note that there is also a package named libmagick++-dev, which is not the same as magick++-dev.  The former will not work, and the two are mutually exclusive.

 Second the Scons build script is horribly broken (SConstruct).  I don't know scons, but I was able to figure out enough to fix it.

It would try to generate commands like

g++ -o IO/AInput.o -c -fPIE -pie "-ggdb `wx-config --cppflags` -Wno-unused-macros" IO/AInput.cpp

The double quotation marks just messing things up.  Additionally, it was missing the correct flags for fftw and audiofile in some cases.

I was able to clean it up enough to this point (I am only posting the bottom part of the file, because the top is just a big list, which I didn't change at all.)


env = Environment();
SConsignFile(".scons-signatures")
env.ParseConfig('Magick++-config --ldflags --libs')
env.ParseConfig('wx-config  --libs --cppflags')
env.ParseConfig('pkg-config fftw3f audiofile --libs')
env.Append(CCFLAGS = '-ggdb')
env.Append(LINKFLAGS = '-ggdb')
env.Program('test_s2i2s',lista);

Another issue which popped up (I'm pretty sure only due to 64 bit architecture) was in Process/Generator/Random.cpp. In the function Random::Random(), you need to replace the line

s1=get32bits()+(int) this;
with
s1=get32bits()+(int) ((intptr_t)this);

and add the include

#include <stdint.h>

to the top of the file.  This basically does the proper cast when ints and pointers aren't necessarily the same size.

Also, the file UI/ParametersDialog.cpp is missing the include

#include <wx/wx.h>

Now, run 

scons

It will build (at least on my system).  It will create the executable "test_s2i2s".  Unfortunately, whenever I try to load a file, it crashes.  If it is an audio file, it says

Audio File Library: could not open file 'test.wav' [error 3]
ERROR: Could not import audio file.

If it is an image file, it says 

test_s2i2s: magick/semaphore.c:525: LockSemaphoreInfo: Assertion `semaphore_info != (SemaphoreInfo *) ((void *)0)' failed.
Aborted

I don't have the time nor energy to track down these bugs, but they seem to be much deeper than misconfigured dependencies.  Hopefully I've sent someone down the right path to getting it to build correctly.

Tuesday, December 7, 2010

Uninstall/Disable feature/plugin in Eclipse Helios (3.6)

Not that I want to editorialize often, but Eclipse is just horrible when trying to remove a plugin.

I tried going to help ->install new software -> check what's already installed... The uninstall option is grayed out for all the relevant plugins.  No indication whatsoever why, or how to fix this.

I instead try going to Help-> Check for New updates.  It simply pops up a dialog saying no updates were found.  No further options.

I try going to Help-> Eclipse marketplace.  It seems Solutions (which are the only things you can modify using this dialog) are different than plugins.

I try going to Help->about eclipse ->installation details.  I get the same menu as if I click install new software.

I try googling.  It either says go to Help->about eclipse ->installation details (which I already tried), or to do  Help -> Software Updates -> Manage Configuration. The second suggestion is simply not available on Eclipse Helios.  I assume I am looking at the documentation for a different version of eclipse.  I find the documentation for Eclipse Helios (3.6), and nope, it's exactly the same.  At this point I hit a lucky break, and I notice that the text describing the menus to open is a link.  I click on it and it says "you can only do this with local help".  I find the same page again in the local eclipse help.  I click the link.  Viola, the magical hidden window pops up that finally allows me do uninstall the plugins.  Did it really have to be that hard?

Saturday, August 14, 2010

Grub not listing Windows (7) installation.

(This works for me on Debian, but probably works on similar systems as well.)

If your grub menu does not list an OS partition which you know is installed, try running update-grub.  If it still isn't listed, try installing os-prober (apt-get install os-prober). This is a program designed to locate non-linux OSes.  Run sudo os-prober.  Hopefully, it will detect the Windows installation you want it to, and it will print out a line indicating the device name and detected OS.  If it doesn't, I can't really help you, but your next step would be to somehow get os-prober to detect the installation.  Assuming you have os-prober detecting the OS as you want it too, try running update-grub again.  It will print out a line indicating that it has detected the installation.  When you reboot, the option should appear on the grub menu.

If os-prober is detecting the OS, but update-grub isn't, look for the file /etc/grub.d/30_os-prober (or something similar), that is the problem (either it isn't installed there, or it is misconfigured).

This really should be the first step you take if it isn't detecting a windows install properly.  No need to do Wndows MBR recovery or any sort of custom grub.d configuration.

EDIT: I found that there can also be issues detecting the install if the Windows 7 bootmgr is corrupted (don't ask me how that happened).  If you start up the windows recovery environment (you can download a recovery CD iso easily if you google) and then recover the boot manager, os-prober will now detect the install.  Just run update-grub to add it to the startup menu.

Thursday, August 12, 2010

Building Tartini on Debian

Tartini is a cool real-time "music analysis" program (http://miracle.otago.ac.nz/tartini/index.html).  The issue is that the sources don't immediately compile on my Debian system.

UPDATE: I've actually gone through and fixed all the issues and created a Debian package for it.  You can download the source at https://github.com/jeremysalwen/tartini-debian  Hopefully it will be in debian too soon.

Obviously, as the instructions say, qt 4, fftw 3, and qwt 5 must be installed for it to compile.  Installing the packages fftw3-dev and libqt4-dev is straightforward.  Make sure that if qt3 is installed, all of the build tools point to the qt4 versions. However, be careful with qwt, as the debian repositories contain a package "qwt-dev" which is not version five.  Instead, install libqwt5-qt4-dev.


As the build instructions state, you then have to modify pitch.pro to tell it where the includes and libraries are.  On a typical debian system, the important part of the file should look like:

unix{
  macx{ #MacOSX
    MY_LIB_PATH += -L/Users/student/usr/local/lib
    MY_INCLUDE_PATH += /Users/student/usr/local/include
  }else{ #Linux
    MY_LIB_PATH += -L/usr/lib
    MY_INCLUDE_PATH += /usr/include/qt4 /usr/include/qwt-qt4 /usr/include
  }
}

Then, qmake will still give you the error

RCC: Error in 'pitch.qrc': Cannot find file 'pics/tartinilogo.png'

For some reason it's looking for a png when the file is really a jpg.  Just modify pitch.qrc to replace tartinilogo.png with tartinilogo.jpg

qmake will then work, but make will still complain about

error: invalid conversion from ‘const char*’ to ‘char*’

a bunch of times.   mystring.cpp and mystring.h are the offending files.  Basically there is a bunch of code that seems to be just *wrong* in how it handles constness.  If you make the local variable "char * ext;" into "const char * ext;" in two functions, and make getFileExtension return type "const char*" instead of "char*", it will work.  (don't forget to change the function in both the cpp and the header file.

Meanwhile, prony.cpp gives a cryptic warning about the included file "cstdio", which seems to be caused by the line:
#define _GLIBCXX_USE_C99

I am not really sure if this affects the functionality of the code, but when I comment it out, it compiles and runs fine.  Apparently there is strange functionality surrounding this symbol anyway: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=443234

You will also get a linking error because it tries to link with -lqwt, when the qwt5 package only provides qwt-qt4.  Again, under the linux section of pitch.pro, replace the line

LIBS += $$MY_LIB_PATH -lfftw3f -lqwt -lasound

with

LIBS += $$MY_LIB_PATH -lfftw3f -lqwt-qt4 -lasound

Still, when you build it, it segfaults when you try to run fixing up calculateAnalysisData in mytransforms.cpp, we replace

if(chunk > 0 ) {
with

if(chunk > 0 && prevAnalysisData->highestCorrelationIndex!=-1) {

To stop the segmentation fault if the previous highest correlation index is -1 (not found).

And that should be enough to get a working Tartini build on Debian.  I would post a diff or a zip of all the corrections, but I can't attach it here.

Thursday, August 5, 2010

Wireless issues on Eeepc under linux

I was running into issues with network-manager (nm-applet) on my Eepc, where at one point I disabled the wireless networking by right clicking on it, but when I attempted to re-enable it, the check box was grayed out.  Restarting and killing the applet did nothing.  In addition, when I tried to connect using iwconfig and iwlist, I was getting errors with "network down".  It seems that at least in my case, the issue was that the interface wlan0 was "down", the solution being "ifconfig wlan0 up".  However, when I tried running that command, I would get the error "SIOCSIFFLAGS unkown error 132".  After some amount of googling, it appears that this error is because of a hardware off switch on the laptop for the wireless.  Confusingly, the Eeepc only had a key combo to disable the wireless, and I was under the impression that it wasn't working under linux, as most of the other hardware hotkey combos didn't.  By pressing Fn-F2, I was able to toggle the Wireless card, and I noticed the little wireless light went on and off.  Surprisingly, it was very inconsistent.  If I pressed it once, sometimes the light and error wouldn't change.  Other times, It would change the light, but get a different error message from ifconfig.  The light sometimes would indicate that it was on, sometimes indicate that it was off.  I figured out that if I pressed it four times and tried ifconfig between each press, at least one of the times it would run without an error.

Turning on the hardware switch meant that the wlan0 interface was "up", allowing me to run iwlist and iwconfig.  However, the issue still remained with network-manager.  Although I assume that the box was initially greyed out because of the hardware switch, it wouldn't un-grey out even when the wireless was back up.  I realized that it was saving the "enabled" state in a configuration file somewhere.  After editing /var/lib/NetworkManager/NetworkManager.state and setting "WirelessEnabled=true", I restarted nm-applet (/etc/init.d/network-manager restart), and suddenly wireless worked again.  Although all the information you need to solve this problem is online, it took several levels of indirection to find it, and a lot of slogging through Ubuntu bug-reports.  I figured I'd compile all the information together here.

Saturday, July 24, 2010

Microcontrollers

I will update this post with more useful tidbits.

I'm dealing with PIC chips here. So far PIC18f*** but I also have a 16f which I might go back to later.

SDCC- Small Device C compiler
You can look up information about SDCC, but the one part that wasn't obvious is the meaning of all the registers included in the header files. They aren't just made up by SDCC. They correspond directly to the names given by the chip manufacturers. So basically if you want to do some SDCC programming, pop open the datasheet of the chip you are looking at, and that will give you an "API" of sorts to use from SDCC.

USB Stack
It seems there are quite a few USB stacks for PICs, but none are *definitive*. Microchip (the company who makes the chips) has their own for their own compiler, but the source is only somewhat open; you can only use it with Microchip devices, so not GPL compatible. A lot of them also seem to be derived from a Nuts and Volts article, which has a GPL source. Right now I'm looking at http://www.microchip.com/forums/tm.aspx?m=382900 which seems promising.

update: with minimal changes I got it to work with SDCC in /usr/ (instead of /usr/local/) and changed it to compile for pic18f4550 instead of 2550.  At least with the minimal changes I made to the makefile, linux recognizes the chip as a USB device when I plug it in.  Here is the source.  It is derived from the above forum post which is derived from the GPL code in the magazine, so it is also GPL.

update: I have found another implementation which seems even better.  It worked with even less modification, and most significantly, it implements USB CDC as well as HID.  This basically means you can do serial port (rs232) emulation with it straight out of the box.  I'm going to need to do some configuration with baud rates for the debug from the actual rs232 port, because right now it's printing garbage.  Here is the source: http://pic-o-rama.org/index.php?option=com_content&view=article&id=2:simple-usb-board&catid=1:evaluation-boards&Itemid=3  Look to the bottom.  This one is also derived from the Nuts and Volts source.