![]() |
2011-02-23
, 20:57
|
Posts: 146 |
Thanked: 15 times |
Joined on Oct 2008
|
#2
|
![]() |
2011-02-24
, 20:50
|
Posts: 52 |
Thanked: 41 times |
Joined on Sep 2010
|
#3
|
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.
#!/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()
self.audiotestsrc = gst.element_factory_make("alsasrc")
The Following User Says Thank You to ukaef For This Useful Post: | ||
![]() |
2011-02-26
, 02:42
|
Posts: 146 |
Thanked: 15 times |
Joined on Oct 2008
|
#4
|
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.
you can run this, its safeCode:#!/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()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
but gst have sources which will play mp3s.Code:self.audiotestsrc = gst.element_factory_make("alsasrc")
good luck!
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.