Reply
Thread Tools
Posts: 52 | Thanked: 41 times | Joined on Sep 2010
#1
Hello,
first of all I want to introduce myself and explaint my lack of knowledge

Im graphics and web designer, I have some skills in PHP, ActionScript. Few years ago I was programming little apps in Delphi (Object Pascal). I dont understand C++ at all, but im trying to learn Python.

Recently I made small app in PyQt.


I want to recieve audio waveform snapshot (smallest piece of waveform which is playing at the output at the phone)

I red about multimedia architecture of maemo - http://wiki.maemo.org/Documentation/...ain#PulseAudio. If Im thinking correctly I have to "ask" PulseAudio for that data.
I found this -> http://maemo.org/api_refs/5.0/5.0-fi...c-example.html but (as I said) I dont understand C++. Is this what im looking for? Is here anyone who can translate for me code to python? I need only one function - that returns sound snapshot in realtime or in specified time laps. Thera are other things described in PulseAudio documentation - http://maemo.org/api_refs/5.0/5.0-final/pulseaudio/ but i didnt understood them too. PLAESE HELP

Edit:
Is there anyone who can tell me what to do to get pyAudio library in python on n900? That could be what im looking for.

Maybe someone know how to get get those PCM data using phonon?

Last edited by ukaef; 2010-10-06 at 16:16.
 
Posts: 146 | Thanked: 15 times | Joined on Oct 2008
#2
Hi,
I also want to make a simple mp3 player for my application using python modules. But I also got no answers. Kind of surprising, actually...

If you find out, please post it here.

Thanks,
L.
 
Posts: 52 | Thanked: 41 times | Joined on Sep 2010
#3
Originally Posted by luis View Post
Hi,
I also want to make a simple mp3 player for my application using python modules. But I also got no answers. Kind of surprising, actually...

If you find out, please post it here.

Thanks,
L.
This is the latest code of my work, before I abandon it. Someone already done what I was trying to do, so it was waste of time. Anyway, if you want to play mp3`s the key is to use gst module.

Code:
#!/usr/bin/python

import pygst
pygst.require("0.10")
import gst
import os
import pygtk
import gtk
import audioop

class Main:
	def __init__(self):
		self.pipeline = gst.Pipeline("mypipeline")
		self.audiotestsrc = gst.element_factory_make("alsasrc")
		self.pipeline.add(self.audiotestsrc)
		self.sink = gst.element_factory_make("appsink", "sink")
                self.sink.set_property('caps', gst.Caps('audio/x-raw-int, width=16, depth=16, signed=true'))
                self.sink.set_property('drop', False)
                self.sink.set_property('max-buffers', 5)
                self.sink.set_property('sync', False)
                #self.sink.connect('new-buffer', self._new_buffer)
                self.pipeline.add(self.sink)
                print('starting...')
		self.audiotestsrc.link(self.sink)
		self.pipeline.set_state(gst.STATE_PLAYING)
                # tmp = 0
                for i in range(1, 999999):
                    #new = ord(self.sink.emit('pull-buffer')[0])
                    # if new > tmp:
                    #os.system('clear') 
                    pipa = abs(audioop.avg(self.sink.emit('pull-buffer'), 2))
                    print(pipa*'x')
        #def _new_buffer(self, sink):
                #buf = sink.emit('pull-buffer')
                #print(buf)
start=Main()
gtk.main()
you can run this, its safe It will print "x" marks on console - as many as the sound output level from the pipeline.

Basically programming music app in python for n900 is about good understanding gstreamer pipelines. You should find example pipelines on google, then use this code to build your own pipeline to play mp3. In my code, source of sound is
Code:
self.audiotestsrc = gst.element_factory_make("alsasrc")
but gst have sources which will play mp3s.

good luck!

p.s. sorry about my english
 

The Following User Says Thank You to ukaef For This Useful Post:
Posts: 146 | Thanked: 15 times | Joined on Oct 2008
#4
Originally Posted by ukaef View Post
This is the latest code of my work, before I abandon it. Someone already done what I was trying to do, so it was waste of time. Anyway, if you want to play mp3`s the key is to use gst module.

Code:
#!/usr/bin/python

import pygst
pygst.require("0.10")
import gst
import os
import pygtk
import gtk
import audioop

class Main:
	def __init__(self):
		self.pipeline = gst.Pipeline("mypipeline")
		self.audiotestsrc = gst.element_factory_make("alsasrc")
		self.pipeline.add(self.audiotestsrc)
		self.sink = gst.element_factory_make("appsink", "sink")
                self.sink.set_property('caps', gst.Caps('audio/x-raw-int, width=16, depth=16, signed=true'))
                self.sink.set_property('drop', False)
                self.sink.set_property('max-buffers', 5)
                self.sink.set_property('sync', False)
                #self.sink.connect('new-buffer', self._new_buffer)
                self.pipeline.add(self.sink)
                print('starting...')
		self.audiotestsrc.link(self.sink)
		self.pipeline.set_state(gst.STATE_PLAYING)
                # tmp = 0
                for i in range(1, 999999):
                    #new = ord(self.sink.emit('pull-buffer')[0])
                    # if new > tmp:
                    #os.system('clear') 
                    pipa = abs(audioop.avg(self.sink.emit('pull-buffer'), 2))
                    print(pipa*'x')
        #def _new_buffer(self, sink):
                #buf = sink.emit('pull-buffer')
                #print(buf)
start=Main()
gtk.main()
you can run this, its safe It will print "x" marks on console - as many as the sound output level from the pipeline.

Basically programming music app in python for n900 is about good understanding gstreamer pipelines. You should find example pipelines on google, then use this code to build your own pipeline to play mp3. In my code, source of sound is
Code:
self.audiotestsrc = gst.element_factory_make("alsasrc")
but gst have sources which will play mp3s.

good luck!
Thansk for your code! It is surprisingly involved. I'd have expected something like module.play(song).

Today I work with madplay or mplayer in a dirty way ("play" calls 'madplay <song>', "stop" kills the subprocess). The good point for me is the volume gain, that allows the N800 to play 15DB louder than max volume (to call birds).

I'll try to see if gst has volume gain.

Thanks!
L.
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 21:16.