Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

Publicaciones sobre kde (publicaciones antiguas, página 12)

Now, this is news to me.

Tavia seems to be an­oth­er KDE web brows­er.

I say nice.

Semi-re­lat­ed:

Be­cause of a ques­tion on the PyKDE list, ask­ing for a more com­plete HTML wid­get us­ing Qt (not kdelib­s) I am look­ing at kde­nox, which is sup­posed to be a Qt-on­ly (QT/E) kon­qy. Per­haps rip­ping off the khtml piece of it won't be too hard, and then it can be sip-wrapped.

Prob­a­bly noth­ing will hap­pen with it, but I am look­ing ;-)

Adventures in Hi-Fi

As I blogged ear­li­er I am writ­ing a game (and yes, it's pret­ty much playable al­ready).

One thing I did­n't men­tion is that I nev­er wrote a game be­fore. Yeah, I know ev­ery­one does it as one of his first pro­ject­s, but I nev­er did.

So, there are some things I re­al­ly have no clue about [1], like sound and mov­ing graph­ics around.

For the graph­ics stuff, QCan­vas is just fine and dandy, but to make things bloop and war­ble and squeak when the time is right, I found Qt's sound sup­port some­what de­press­ing.

Come on, NAS? Who us­es that? And what about mu­sic? I had no idea.

So, I start­ed try­ing to fol­low one of my lead­ing prin­ci­ples of de­vel­op­men­t: find a way to make it Some­one Else's Prob­lem (T­M).

The usu­al way to do that is find­ing a li­brary that han­dles the prob­lem, write min­i­mal glue, stick it to the side of the pro­gram, tell the pro­gram that's his new ar­m, and for­get about it quick­ly.

Here's what I found.

Mi Dios!

I thought I should start by adding one of those an­noy­ing lit­tle tunes ev­ery game has. It's just a game tune, I don't want to have to in­clude a 3MB OGG file for it, so I want­ed an in­stru­men­t-based for­mat.

I re­mem­bered MI­DI tunes. You may know them as ring­tones nowa­days, but they used to be just cheesy tunes gen­er­at­ed by your SBPro's FM gen­er­a­tor, not your phone.

In fac­t, I re­mem­ber hav­ing a lit­tle prog­gie called playmidi, that would do that in Lin­ux.

Well, it seems that in the past few years, ei­ther sound cards have for­got­ten how to play them, they fell out of fash­ion, or some­thing, be­cause the on­ly things I found that could play MI­DI are mon­strosi­ties that re­quire a 9MB dig­i­tal in­stru­ment set. And how was I to in­clude that along with my 25KB game???

So, what's nex­t? I had a C64, so...

MOD me up!

MOD files are like MI­DI files, on­ly the MOD in­cludes it's own in­stru­ment set, called sam­ples, and in­struc­tions on how to re­peat and al­ter those sam­ples to make a tune.

Good news: there are nice-­sound­ing, fun­ny MOD files that are about 30KB in size.

Bet­ter news: There is a pop­u­lar li­brary to play them! It's called Mik­mod, and your dis­tro has it (and it's a de­pen­den­cy for KDE's mul­ti­me­dia pack­ages too).

Even bet­ter news: It has sup­port for play­ing sim­ple sounds (sam­ples in mod lin­go) by call­ing a cou­ple of func­tion­s.

Awe­some news: It in­cludes a soft­ware mix­er so you can just tell it to play this, then play that, then that, and a tune in the back­ground, and ev­ery­thing sounds at the same time.

So, we have a win­ner. This ba­by can han­dle ev­ery­thing I need for the game!

But... is that a snake in your pock­et?

I can't find a Python bind­ing for it. I am sure as soon as I post this ar­ti­cle some­one is go­ing to come up and tell me, here they are, mo­ron! But I just can't find any.

So, I de­cid­ed to do some­thing I want­ed to do al­ready and learn to use Pyrex. Pyrex is a tool to write python ex­ten­sion­s, with al­most-free ac­cess to C li­braries, in an al­most-python lan­guage (on­ly mi­nor syn­tax dif­fer­ences).

That way, I could write a Python mod­ule to use Mik­mod.

You know what? It was al­most scar­i­ly sim­ple [2]. I did­n't wrap all of Mik­mod [3] be­cause I don't need it, but now I can do stuff for games and apps al­most triv­ial­ly.

Even more: Pyrex has awe­some dis­tu­tils sup­port, so build­ing the ex­ten­sion­s, usu­al­ly a pain in the rear, is triv­ial (most­ly you just copy and delete stuff, with some search and re­place).

One thing I found I did nice­ly is this: Mik­mod re­quires you to call Mik­mod­_Up­date ev­ery once in a while so it fills the sound­card's buf­fer with stuff to play. If you don't, it skip­s.

So, I just start­ed a thread that loops and takes care of it. You don't even have to know about it to use the ex­ten­sion. Oh, sure, if your Mik­mod is not thread­safe, it break­s. Well, get a de­cent Mik­mod pack­age, then.

How does it look?

Here's a whole noisy prog­gie

#Load the modules
import mikmod, time
#Init the library
mikmod.init()
#40 voices, 20 for music, 20 for random sounds (overkill)
mikmod.setNumVoices(20,20)
#Enable sound, starts the thread that pushes sound, too
mikmod.enableOutput()

#Create a module, that is, a music track
module=mikmod.Module("BasicInstinct.mod")

#Load two samples, just a couple of noises
s1=mikmod.Sample("lost.wav")
s2=mikmod.Sample("swap.wav")

#Start playing the song
module.play()


#For the duration of the song, each second, make some noise


while module.active():
        s1.play()
        time.sleep(0.5)
        s2.play()
        time.sleep(0.5)

#Close the mikmod library, stop the thread, etc.

mikmod.exit()

Shopping for a notebook

Ok, I want to re­tire my note­book. It's about to turn 10 years old, which is about 270 in note­book years, so it's time.

I've been re­search­ing a bit, and here's my re­quire­ments:

  • Cheap. About USD 950 would be fine

  • Smal­l.

  • Light.

  • Enough pow­er to run KDE de­­cen­t­­ly.

  • Should work with lin­ux. Noth­ing very fan­­cy, but it be­ing able to sus­pend would be nice ;-)

  • DVD read­­er, CD writ­er. DVD writ­er would be nicer but con­sid­er cost.

I've been look­ing ten­der­ly at a Av­er­atec 3220. It seems to ful­fill all the re­quire­ments ex­cept it seems not to work so well with Lin­ux.

Be­fore any­one say it's not pow­er­ful enough: My desk­top has a slow­er CPU (A Duron) and I like it just fine.

The screen is rather small­ish, but that's part of be­ing small and light, I con­sid­er the 12" screen a plus.

If any­one knows of a bet­ter sys­tem in this price range (the Av­er­atec can be found for about USD 890 or so), or of a cheap­er way to get one, please com­ment here!

Back in the saddle

Should start post­ing stuff again now. Wait, this is a post! Talk about a self­-­ful­fill­ing prophe­cy!

Lots of things hap­pened in this very long break, so I won't both­er even men­tion­ing any of them, ex­cept one, which I promised to.

I am in love. And I will, as promised (to her), post a lit­tle love let­ter in my blog, and in­vite com­ments.

Since the long post­less pe­ri­od prob­a­bly means no­body reads my page any­more ex­cept when find­ing it via google, I in­vite any­one read­ing it in plan­etkde or wherever, to go to my page us­ing the handy link that should be some­where around this tex­t, and post a com­ment if you wan­t.

Be nice, please, be­cause delet­ing com­ments from pycs is some­what of a chore.

And here it goes:


Rosar­i­o, I love you. Some­times you think I don't, but that's just be­cause my skills of fa­cial and ver­bal ex­pres­sion are aw­ful. I love you when you act sil­ly, or pout, or say wild stuff.

I don't love you be­cause you pout or act sil­ly, but pout­ing and sil­ly­ness is sim­ply the ac­cen­t, love­li­ness is the lan­guage that you speak, and I can't do any­ht­ing but lis­ten to it.

These last two months have been most­ly hap­py for me, and when they weren't, they were hap­pi­er than they would have been with­out you, and I hope you felt the same thing.

Now you blush, girl.


Com­ming soon, the usu­al tech­ni­cal driv­el.

Would a sock suck if a sock could suck?

Clee: it's re­al­ly quite sim­ple, IMVHO.

If the goal of plan­etkde is to syn­di­cate blogs about KDE, then you should on­ly ag­gre­gate feeds that are about KDE. The god­dess knows mine is­n't, ex­cept oc­casi­nal­ly (y­ou should use this one in­stead (it is bor­ing and emp­ty, though).

How­ev­er, if the goal of plan­etkde is to syn­di­cate the blogs of kde-re­lat­ed peo­ple, then you just ag­gre­gate them (with the agree­ment of the blog­ger) and that's that.

If some­one posts some­thing strange or sad or what­ev­er, the oth­ers can post replies, en­cour­age­ments, what­ev­er, and life goes on.

Since it's your site, you are the one that choos­es. I would pre­fer the sec­ond ap­proach, though.


Contents © 2000-2023 Roberto Alsina