Entries Tagged as ''

Removing Pulse Audio from Ubuntu hardy 8.04 and replacing with esound and back again

Ok… My sound system has pretty much hosed ever since I installed 8.04. It hasn’t been a big deal, but my little one has been wanting to play games on my computer and it sort of stinks not having sound. I’m not in the mood to go 8.10 and I don’t want to screw around with this for too long…. So I’m going to try something hopefully pretty quick and dirty.
According to this post this is what you need to do:

PulseAudio Removal

If you decide you no longer like PulseAudio and would like to disable it: Remove the added lines to /etc/asound.conf If /etc/asound.conf did not exist when you installed PulseAudio, you may remove /etc/asound.conf entirely.

After this, you may remove all of the installed PulseAudio packages.

To disable pulseaudio in hardy you need to select alsa for for all options in /system/preferences/sound

Ok… Lets see what we got.

onas@Ubuntu4:~$ locate asound.conf
/usr/share/doc/libasound2-plugins/examples/asound.conf_jack
/usr/share/doc/libasound2-plugins/examples/asound.conf_oss
jonas@Ubuntu4:~$

Ok… that’s bizarre no files….
So… I was just reading this thread….http://ubuntuforums.org/archive/index.php/t-778351.html Apparently, others had the same issue….
Next try… I basically fired up synaptic and put in pulse audio and marking everything that showed anything to do with pulse audio to remove it. There was two library which had links to games… libpulse-mainloop-glib() and libsdl1.2debian-pulseaudio that if I uninstalled would have taken out alot of games also, so I left that alone for now…
Anyway…
Now lets see…
I read through that thread and it sounds like there could be issues getting esound to run…..
Time to look at this thread.
http://ubuntuforums.org/showthread.php?t=855764

Looks like bad things might happen… Time to save and publish this post.. In case I need to look at this on another computer…
Ok… At this point from the terminal I:
sudo apt-get install esound
sudo gedit /etc/esound/esd.conf
and changed autospawn from 0 to 1. I have no Idea what that does but I thought I’d try……
Hears the moment of truth…
I’ll be back in a couple after rebooting… (hopefully)
Ok…. So much for the quick fix….
I’m going to try to remove esound and try pulse one more time with this link.
I just did a:
sudo apt-get remove esound
sudo apt-get install pulseaudio

I want to use alsa, so it says to do the following:

ALSA Applications

If the PulseAudio plugin for alsalibs is installed all applications with support for the ALSA API should be able to access a PulseAudio server. You need version 1.0.12 or newer of the ALSA packages for the PulseAudio plugin to be included.

To activate the driver edit /etc/asound.conf or ~/.asoundrc and add:

pcm.pulse {
type pulse
}

ctl.pulse {
type pulse
}

I don’t have a asound.conf but I do have asound.rc
soo….. In it goes.

I tried the test and this is what happened.

jonas@Ubuntu4:~$ aplay -Dpulse foo.wav
ALSA lib pcm.c:2104:(snd_pcm_open_conf) Cannot open shared library /usr/lib/alsa-lib/libasound_module_pcm_pulse.so
aplay: main:564: audio open error: No such file or directory
jonas@Ubuntu4:~$

Supposedly to fix that you need to do this.
apt-get install libasound2-plugins
Ok,,, Now I’m getting a different error but it’s time for me to go…

Working through the zetcode wxwidgets tutorial:Device Contexts:Gradient

Ok… The air has been let out of my sails a bit with this LGPL but darn it, I made a commitment to myself that I was going to finish this tutorial….. So onewards….

So this example uses gradient, which is a smooth blending of shades and blending. Very pleasent sort of stuff. The codes on the zetcode site.

Actually this looks sort of easy:

  dc.GradientFillLinear(wxRect(20, 20, 180, 40), col1, col2, wxNORTH);

col1,col2 are two colors that are blended into each other in the direction given…

On to shapes:
This is a very interesting example. On polygons, splines points are put in a array and then displayed through
dc.DrawPolygon(4, polygon);

Working through the zetcode wxwidgets tutorial:Device Contexts:Pen/Regions

Everything, is fairly straight forward in the pen example. It uses wxDC::DrawRectangle where is an abstract data class for wxPaintDC. Basically a bunch of rectangles are drawn with different patterns.
The patterns are defined constructor in wxPen

So… on to Regions… Now piece of sample codes gets a little more interesting to me…
This is one of those instance where a picture is worth a thousand words…

On a side note, at some point I need to get back to drag and drop. I just fired up Inkscape and dragged and dropped the png into it.  I’m thinking about adding some  some notes on the graphic.  I’m going to have to learn how to do that… I basically bypassed it in this tutorial..

In zetcode’s sample code nearly each set of squares is build around the same template.

dc.SetBrush(wxBrush(white));
dc.DrawRectangle(100, 20, 50, 50);
dc.DrawRectangle(110, 40, 50, 50);
wxRegion region1(100, 20, 50, 50);
wxRegion region2(110, 40, 50, 50);
region1.Intersect(region2);
wxRect rect1 = region1.GetBox();
dc.SetClippingRegion(region1);
dc.SetBrush(wxBrush(red));
dc.DrawRectangle(rect1);
dc.DestroyClippingRegion();

Ok.. lets see. SetBrush, Drawrectangle, been there/ done that..
wxRegion, SetClippingRegion , DestroyClippingRegion are new for me.

I basically copied this from the wxsite

wxRegion

A wxRegion represents a simple or complex region on a device context or window.

This class uses reference counting and copy-on-write internally so that assignments between two instances of this class are very cheap. You can therefore use actual objects instead of pointers without efficiency problems. If an instance of this class is changed it will create its own data internally so that other instances, which previously shared the data using the reference counting, are not affected.

Derived from

wxGDIObject
wxObject

Include files

<wx/region.h>

See also

wxRegionIterator

Members

wxRegion::wxRegion
wxRegion::~wxRegion
wxRegion::Clear
wxRegion::Contains
wxRegion::ConvertToBitmap
wxRegion::GetBox
wxRegion::Intersect
wxRegion::IsEmpty
wxRegion::IsEqual
wxRegion::Subtract
wxRegion::Offset
wxRegion::Union
wxRegion::Xor
wxRegion::operator =

Qt and the game plan

Ok… So I get emailed this press release by Nokia that their changing their licensing model from GPL to LGPL..  In my little world this is a huge deal.  In my digital wanderings I stumbled on QT and started working with it.  The technology impressed me but the dual license model was a real turn off.  Basically, it you wanted to have any type of proprietary code, you were obligated to publish it as open source, unless you purchased a license from QT (formally trolltech).  We’re not talking a 10 buck license but some serious shekels for a small fish.  So basically, the choice was to  be altruistic and give it away or a big fish to make money with it.

My decision to study wxwidgets was primarily based on the license model for QT.  I’m going to need let the dust settle on this and see where this is heading.  For now, I guess I’ll stay the course, although my suspicion is that I’ll being dusting off the QT.

I think that this is going to be very interesting for Freecad which uses QT and Opencascade.   My understanding is that Freecad is very close to coming of age and I think this will tend to accelerate it’s development, especially in todays economy.

I think that I’d be pretty upset right now if I was a small to middle sized developer who was making money with QT.  The competition has just swelled.

Nokia is not a stupid company,  I wonder if this is part of a strategy to take on Apple the same way as they basic took out Motorola in the cell phone days.  I need to do a little more research on this.

Searching on history on wxWidgets.

Ok… It’s Sunday morning, its quite, I should really be pounding away at the zetcode tutorial, but I catch myself surfing.. Well, at least I’m surfing on topics related to wxWidgets.
I found a couple of interesting links that I want to go back to a peruse a little bit more.
I found a 2002 article that talks about the 10′th anniversary of wxWidgets. One of the things that caught my eye was there was some discussion about wxODBC, which is something, I’m going to be interested in looking at in the near future..

Besides, that there I found a couple of intro site… Part 1 and Part 2. . I wouldn’t call these must read’s but lets call it somewhat interesting.

Ok… Need to get back to zetcode before the house wakes up…….

Working through the zetcode wxwidgets tutorial:Device Contexts:Point

This pc of sample code is sort of fun… It brings back lots of memories.. from my qbasic days…. (Oh boy… am I dating myself…)
Anyway… Need to load it up and see what catches my eye.

#include “points.h”
#include
#include

Points::Points(const wxString& title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(280, 180))
{

this->Connect(wxEVT_PAINT, wxPaintEventHandler(Points::OnPaint));
srand(time(NULL));
this->Centre();
}

void Points::OnPaint(wxPaintEvent & event)
{
wxPaintDC dc(this);

wxCoord x = 0;
wxCoord y = 0;

wxSize size = this->GetSize();

for (int i = 0; i<1000; i++) {
x = rand() % size.x + 1;
y = rand() % size.y + 1;
dc.DrawPoint(x, y);
}
}

These programs bring back some memories… I remember doing some art work with some quick basic on my original IBM …. Poor old thing when to  recyclers this weekend ;(
I guess the thing that catches my eye is not so much wx stuff… but this
srand(time(NULL));

Pretty standard stuff… Just the C++ version of doing things.

The more I see this stuff, the more I’m starting to like it.
Trying to deal with: “wxSize size = this->GetSize(); ” kind of stuff in Vb was always pain.

x = rand() % size.x + 1;

For some reason, I always had disdain over the modulus operator.. It just seems wrong.. But I know it’s used alot in computer science so I guess I need to deal with it.
Mentally I’m having a difficulty wrapping my head around why the modulus “%” operator works here
Sometimes things are just a little too succinct.. Maybe I should take the time to understand whats going on here..

I was doing some surfing at lunch a I came across this very interesting post by a guy called phridge back in 01.
Ok.. so…

I think you misunderstand what the modulo does. Modulo evaluates the following: a % b = c => b*k + c = a. Where we find some integer k that satisfies that relation. In the case of non-negative integers this is the same as the remainder of dividing a and b. The remainder is 2 in your case, since 18 % 8 = 2 => 8*2 + 2 = 18. Not .25, which is 2 / 8. Or, IOW, the remainder divided by the dividend.

That makes sense
x = rand() % size.x + 1;
Focusing in on:
rand() % size.x

a % b = c => b*k + c = a.

I guess I should study a little about the wxString functions to help adding debugging text
http://docs.wxwidgets.org/stable/wx_wxstringoverview.html

Ok… Here is a little tidbit that sounds interestings:
The usage of std::string compatible functions is strongly advised! It will both make your code more familiar to other C++ programmers (who are supposed to have knowledge of std::string but not of wxString), let you reuse the same code in both wxWidgets and other programs (by just typedefing wxString as std::string when used outside wxWidgets) and by staying compatible with future versions of wxWidgets which will probably start using std::string sooner or later too.

That actually is rather pragmatic and makes sense.
Ok.. This sort of an interesting wiki link

At this point, I just want to use cout with wxstrings (not claiming  I know what I’m doing here… But this looks interesting: http://lists.wxwidgets.org/pipermail/wx-users/2007-April/099124.html

This link discusses how to use cout with wxString..
Ok.. I guess I should give it a go..
Back to the rand().  I think I just figured out what is causing my confusion…..
In vb6 the rnd returns a single that between 0 and 1. That’s not what’s going on with rand since its return a int between 0 to at least 32767 depending on implemention.

Ok… At the risk of sounding like a bushim…. I unconfused myself :) … Finally, I can advance to the next module..

PC’s, Memories and Electronic Recycling day.

Ok… So we electronic recycling this weekend, and my wife has people coming over so there was a slightly accelerated urgency to get my computer graveyard moved into the van.   I guess in one way of me not being able to let go and partly out of privacy paranoia, I yanked the hard drives…
There was my original 8088 IBM Pc with a 10 meg drive.  I also had my Zenith 286 laptop that went with me to Germany….  My honking full height Gateway 486 that was my PC before we got married…  Ah… the days of Doom… This is very strange for me..  I don’t hold any sentimentality for any of the PC’s that are still in my stable…. but these somehow, I’m somewhat sad to see them go, but I have to say it is sort of nice to have the room.
It would be interesting so retrieve the data if posible off of the drives…

Working through the zetcode wxwidgets tutorial:Device Contexts:Simple Line

If anyone besides myself is reading this blog will notice that I’m blowing off to pieces of sample code..

Basically, I’m ignoring (for now)

  • zetcode:widgets II: scrolled window
  • zetcode:drag and drop.

I don’t tend to use that stuff in my vb6 stuff and I’m running out of fun free time. I was looking at the code for the drag and drop and I don’t want to invest the time to understand whats going on there for the moment.

Anyway…
That brings me to simple line.

This code is actually pretty easy..

#include “Line.h”

Line::Line(const wxString& title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(280, 180))
{
this->Connect(wxEVT_PAINT, wxPaintEventHandler(Line::OnPaint));
this->Centre();
}

void Line::OnPaint(wxPaintEvent& event)
{
wxPaintDC dc(this);

wxCoord x1 = 50, y1 = 60;
wxCoord x2 = 190, y2 = 60;

dc.DrawLine(x1, y1, x2, y2);
}

“OnPaint” fires on a resize event.
The thing that struck me a curious is the wxCoord’s.
This is an interesting post that explains it
This seems very straight forward on to the next item.

Working through zetcodes’s wxwidgets tutorial:Widgets II,wxNotebook

So…. One day left before I head back to work…. I really should be painting at the moment, but this is so much more fun..
Ok.. I’m looking at this applications which uses the grid control. It’s sort of cute it looks like a spread sheet.
A couple of thoughts here..
How to I sort a grid.
How to I merge cells.
How do I dump the results of an sql query into it…
Time for some quick googling>>>
Nothing is jumping out at me.. I  put a post on wxforums about this… I guess we’ll see  what the comments are.
Anyway… on to the next one.

Working through zetcodes’s wxwidgets tutorial:Widgets II,wxListbox

I’ve made it to the next section, Widgets II of the zetcode tutorial.   I’m running out of vacation time, and I probably s/b painting but, this stuff brings me pleasure..
Anyway….. bunch of things on my mind…. none of which are suitable for a public blog…

To the tutorial..
wxListbox has two states… blah blah… single or multiple selection state…

The two main events are click and double click for wxListbox

So I guess it’s time to give this a roll.
This is a nice example with a bunch of interesting stuff going on..
Along with the list box, an insert, rename, delete and clear buttons…

Lets see if something jumps out at me with the source…
Well, for a while we were ignoring the boxsizers… now they’re back.
One thing that caught my eye was wxGetTextFromUser.
I poke around that section of the documentation…. There are all sorts of goodies in there..
Either the examples are getting easier or I’m starting to get the hang of this stuff… The only thing that really stumped me at the moment was:

void MyPanel::OnRename(wxCommandEvent& event)
{
wxString text;
wxString renamed;

int sel = m_lb->GetSelection();
if (sel != -1) {
text.Printf(m_lb->GetString(sel));
renamed = wxGetTextFromUser(wxT(“Rename item”),
wxT(“Rename dialog”), text);
}

if (!renamed.IsEmpty()) {
m_lb->Delete(sel);
m_lb->Insert(renamed, sel);
}
}

I need to refill my coffee cup, sit back and ponder that one for a moment or two..
Ok….
I changed the code and it seems to work ok.

I’m starting to get interested in good practise.. I found this link on programming style and I submitted a question to the wxforum regarding the .printf thing