• Recent blog posts

    • Using jack/alsa as main server and coexisting with pulseaudio (and s/pdif)

      Date: 2012.11.18 | Responses: 0

      Every now and then I revisit Jack as various real-time audio applications require it (Ardour in my case).  However, I never could get Jack to play nice with pulseaudio, flash, and s/pdif.

      Here I try to recount how I managed to get an “acceptable” setup.

      First of all, I decided to use alsa as the driver behind jack. I assume you are using pulseaudio and on debian amd64 and that you know how to start the jack server (I use qjackctl with server prefix “pasuspender — /usr/bin/jackd” — see screenshot below). I am also assuming you want to be running jack for your day-to-day use, thus you will need to make sure jack is started everytime your computer is started (I added qjackctl to the gnome session — run “gnome-session-properties”). Finally, as you’re troubleshooting, make sure to restart jack whenever you make the changes below.

      So first, make sure you have alsa installed with:

      apt-get install alsa-base alsa-utils

      Next let’s get pulseaudio sorted out by telling it to use jack (instruction based on jack wiki). Create or edit ~/.pulse/default.pa with:

      load-module module-native-protocol-unix
      load-module module-jack-sink channels=2
      load-module module-jack-source channels=2
      load-module module-null-sink
      load-module module-stream-restore
      load-module module-rescue-streams
      load-module module-always-sink
      load-module module-suspend-on-idle
      set-default-sink jack_out
      set-default-source jack_in

      Also create or add to ~/.pulse/client.conf . You may not need this after you restart pulseaudio (but initially this will help for debugging).

      autospawn = no
      You may also want to kill pulseaudio with 
      pulseaudio -k

      That should take care of pulseaudio. Next let’s make sure flash in your browser will use jack. For this we will manually install libflashsupport-jack (based on instructions from linuxmusicians.com and ffdao wiki). Note the git repository is different than in the original instructions, this is to support Linux kernel >=  2.6.38 (which most of you should have).

      apt-get install build-essential git-core autoconf automake libtool libasound2-dev libjack-dev libsamplerate0-dev libssl-dev
      git clone git://repo.or.cz/libflashsupport-jack/new-kernel-support.git
      cd new-kernel-support
      sh bootstrap.sh
      make
      sudo make install

      We’re almost done, you most likely will need to update /etc/asound.conf (or ~/.asoundrc) with the following. Afterwards, make sure you restart your browser to test a flash video.

      pcm.!default {
          type plug
          slave { pcm "jack" }
      }
       
      pcm.jack {
          type jack
          playback_ports {
              0 system:playback_1
              1 system:playback_2
          }
       
          capture_ports {
              0 system:capture_1
              1 system:capture_2
          }
      }
       
      ctl.mixer0 {
          type hw
          card 0
      }

      Finally, I was worried alsa/jack would not send audio to my A/V receiver through s/pdif, but I was quite surprised that I didn’t have to make any changes to my alsa/jack setup besides making sure that in qjackctl setup I had “Output Device” set to the correct card/channel. However, if you want to watch movies/dvds with surround sound through s/pdif, you will need to stop the jack server and use purely alsa (it works automatically with VLC).  If you’re having trouble with s/pdif, I would first test in with jack stopped and follow the troubleshoot notes at http://www.mythtv.org/wiki/Configuring_Digital_Sound_with_AC3_and_SPDIF#Digital_Sound.

      qjackctl setup

    • Cloning partitions/files and keeping permissions

      Date: 2012.08.27 | Responses: 0

      When moving my Debian system from my HDD to an SSD, I first used cp which left me with my OS having all kinds of problems due to permissions. Then I googled and found this solution that worked like a miracle:

      cd /old/path
      find . -depth -print0 | cpio --null --sparse -pvd /new/path/

      Source

    • RVM and system ruby gotcha as root in Linux

      Date: 2012.07.31 | Responses: 0

      If you have rvm installed, but you want to mess with an app that uses system ruby, don’t go on a terminal as the rvm user and then do sudo or su root, as that will still use some parts of rvm that were set through your .bashrc file, even if you didn’t stall rvm for the whole system.  You will also spend a while pulling your hair out.

      Rather, avoid reading the rvm user’s .bashrc by  either use a tty terminal to sign in as root or in gnome use the “Root Terminal” application.

    • Useful information about alsa

      Date: 2012.07.07 | Responses: 0

      libasound2 provides the file /usr/share/alsa/alsa.conf and the directory above it.

    • Associations accross a joining table that uses polymorphic associations in rails 1.2.6

      Date: 2012.03.22 | Responses: 0

      Update: I’m using rails 1.2.6 which does not seem to support :through, :source with has_one associations (the docs don’t show it listed). An alternative is to use “has_many :categories” instead and then create helper method “category” to return a single category.


      Say you have a subjects table that will contain two types of classifications and they are differentiated by a flag, let’s call them subjects(flag off) and categories (flag on).

      Then we have a joining table that will serve as a polymorphic join between all kinds of models and the classifications “subjects” and “categories”. As an example, one of these models will be Resource. “resources” is its respective table.

      subjects
      --------
      ID
      name
      flag
      items_classifications
      --------
      ID
      item_id
      item_type
      classification_id
      resources
      --------
      ID
      name
      ...

      Now I have made the following associations in the models.

      class Classification < ActiveRecord::Base
        set_table_name :subjects
        has_many :items_classifications
      end
      class ItemsClassification < ActiveRecord::Base
        belongs_to :item, :polymorphic => true
        belongs_to :classification
      end

      The Resource model is the tricky one as I only want the resource model to have one “category,” however the console throws up every time I try to instantiate a Resource instance and the problem lies with my “has_one :category” definition. Interestingly, “has_many :subjects” is handled just fine.

      class Resource < ActiveRecord::Base
        has_many :items_classifications, :as => :item,  :dependent => :destroy
        has_many :subjects, :through => :items_classifications, :source => :classification, :conditions => ["subjects.flag IS NULL"], :order => 'subjects.name'
       
        #throws error:
        has_one :category, :through => :items_classifications, :source => :classification, :conditions => ["subjects.flag IS NOT NULL"], :order => 'subjects.name'
      end

      The exact error it throws is the following:

      ArgumentError: Unknown key(s): through, source

      This is strange as the docs say those keys are ok: http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#method-i-has_one

      If you have any idea how to make this work or if it’s even possible, let me know!

    About me

    1

    I live in Denver, Colorado and work as a contractor for HAIKU Learning Systems, Inc., an online learning company. I did my Master's in Music Informatics at Indiana University and got a B.A. in Computer Science and Mathematics, with a minor in Music from Carroll College in Helena, Montana.

    Resume Contact me

    Blog Tags