Active Topics

 


Reply
Thread Tools
helex's Avatar
Posts: 543 | Thanked: 802 times | Joined on Apr 2010 @ Germany
#1
Hi Folks!

In my opinion I have now a great Idea for a application to learn and contribute to the first N900 coding competition.

Yes, it will be great! But I don't want to share my Idea now... (Apple could steal it before I finished it)

It's a lot of work to do. So I will begin soon to finish before the deadline. I finished the script and some mockups for the UI, I know how to store in a Database, how to read binary files... I guess I can figure out how to draw images on the screen, store them on mmc1 and to see if the battery is charging. No problems so far for my, only work... except one of the core elements I don't know how to solve...

Without that the application is useless. So, I hope here is someone who can help me to finish my (top secret) project in PyQt4:

I need to read every 100ms the volume peak, the average input level or the maximum input level or something similar from the microphone. I don't want to record the stream or something else... just: noise out there, 20% of 100% maximum peak or 80%? A simple integer value how loud the environment is. I don't need more.

Are there someone out there who could show me the way?

I looked into the code of Tuner, but its to much for my needs and C++.

Is portaudio19-dev useful for me?

So please help so that I can start with my project!
 

The Following User Says Thank You to helex For This Useful Post:
mikec's Avatar
Posts: 1,366 | Thanked: 1,185 times | Joined on Jan 2006
#2
If you are using PR1.2 then the QtMultimedia stuff is what you need.

see the blog

http://labs.trolltech.com/blogs/2010...trum-analyser/
__________________
N900_Email_Options Wiki Page
 

The Following User Says Thank You to mikec For This Useful Post:
helex's Avatar
Posts: 543 | Thanked: 802 times | Joined on Apr 2010 @ Germany
#3
Originally Posted by mikec View Post
If you are using PR1.2 then the QtMultimedia stuff is what you need.

see the blog

http://labs.trolltech.com/blogs/2010...trum-analyser/
Mh, nice. PR1.2 is comming tomorrow.

I don't need it graphically shown... But I hope I can extract somewhere my needed Values...
Sadly, I can't find QMultimedia at the PyQt4 bindings: Class Reference

Can I implement QMultimedia then in a direct way?
 
helex's Avatar
Posts: 543 | Thanked: 802 times | Joined on Apr 2010 @ Germany
#4
Okay, here now the PyQt4 class reference for QtMultimedia

But when I try to read from the defaultInputDevice() I get the error:
Code:
ALSA lib pcm.c:2211: (snd_pcm_open_noupdate) Unknown PCM null
So, to find out what I'm doing wrong I created this fast code:
Code:
from PyQt4 import QtMultimedia

devi = QtMultimedia.QAudioDeviceInfo.availableDevices(QtMultimedia.QAudio.AudioInput)
for d in devi:
    d.deviceName()
    
devo = QtMultimedia.QAudioDeviceInfo.availableDevices(QtMultimedia.QAudio.AudioOutput)
for do in devo:
    do.deviceName()

info = QtMultimedia.QAudioDeviceInfo(QtMultimedia.QAudioDeviceInfo.defaultInputDevice())
print info.deviceName()
I expected to have a result of input and output devices and the last one the default Input Device (microphone). But I get only null at the command line. The Lists devi and devo are empty.

What's wrong? Have I to activate the sound devices before? I haven't found anything like this in the class reference nor in your c++ example.
 
mikec's Avatar
Posts: 1,366 | Thanked: 1,185 times | Joined on Jan 2006
#5
I have not used it yet, but will do soon. Did you have a look at the multimedia example

http://doc.qt.nokia.com/4.6/examples-multimedia.html

And the ref python doc
http://www.riverbankcomputing.co.uk/...a.html#details
__________________
N900_Email_Options Wiki Page

Last edited by mikec; 2010-05-27 at 19:01.
 
helex's Avatar
Posts: 543 | Thanked: 802 times | Joined on Apr 2010 @ Germany
#6
Originally Posted by mikec View Post
I have not used it yet, but will do soon. Did you have a look at the multimedia example

http://doc.qt.nokia.com/4.6/examples-multimedia.html
No, I looked mostly in the engine module from the Trolltech Qt example:
http://qt.gitorious.org/qt/qt/trees/...s/spectrum/app

But what I saw there was very similar to your example in:
http://doc.qt.nokia.com/4.6/multimed...input-cpp.html


I tryed to translate it into Python. But I failed in the early begining with the identification of the audio devices:
http://doc.qt.nokia.com/4.6/multimed...vices-cpp.html

Originally Posted by mikec View Post
And the ref python doc
http://www.riverbankcomputing.co.uk/...a.html#details
Yes, I worked with it, but it seems I'm missing someting.

Here is the TESTING code I have at the moment: (I know, it's not well done and I need a Timer before stoping the recording. But without the fundamentals and essential defaultInputDevice its useless to polish it)

Code:
from PyQt4 import QtMultimedia
from PyQt4.QtCore import *

file = QFile()
file.setFileName("testMicIn.wav")
file.open(QIODevice.WriteOnly)

format = QtMultimedia.QAudioFormat()
format.setFrequency(8000)
format.setChannels(1)
format.setCodec("audio/pcm")
format.setByteOrder(QtMultimedia.QAudioFormat.LittleEndian)
format.setSampleType(QtMultimedia.QAudioFormat.UnSignedInt)

info = QtMultimedia.QAudioDeviceInfo(QtMultimedia.QAudioDeviceInfo.defaultInputDevice())

print "-"
devi = QtMultimedia.QAudioDeviceInfo.availableDevices(QtMultimedia.QAudio.AudioInput)
for d in devi:
    d.deviceName()
    
devo = QtMultimedia.QAudioDeviceInfo.availableDevices(QtMultimedia.QAudio.AudioOutput)
for do in devo:
    do.deviceName()

print "-"

print info.deviceName()

print info.isFormatSupported(format)

format = info.nearestFormat(format)
print info.isFormatSupported(format)



audio = QtMultimedia.QAudioInput(format, None)

audio.start(file)



audio.stop()
file.close()
del audio

Last edited by helex; 2010-05-27 at 22:23.
 
Posts: 3 | Thanked: 5 times | Joined on Nov 2009
#7
I haven't tried any Qt4.6 development but have managed to get python to monitor mic audio levels using gstreamer tools

pipeline = gst.parse_launch("pulsesrc ! level message=true ! fakesink")
bus = pipeline.get_bus()
bus.enable_sync_message_emission()
bus.add_signal_watch()
bus.connect("message::element", on_message)
pipeline.set_state(gst.STATE_PLAYING)

then create a callback function that acts on the message retuned from the level monitor (you can control the frequency of the level sampling too)
 

The Following User Says Thank You to gavinmitchell For This Useful Post:
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#8
Helex, ever figure this one out? i'm struggling on QtMultimedia now
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 

The Following User Says Thank You to noobmonkey For This Useful Post:
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#9
Could be related too a QT bug here? - http://bugreports.qt.nokia.com/browse/QTBUG-10729
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 

The Following User Says Thank You to noobmonkey For This Useful Post:
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#10
Ok not sure it is related to this bug - http://bugreports.qt.nokia.com/browse/QTBUG-5723
But i'm still digging
aplay -L shows pulseaudio as our only method... But at least that shows something i spose!
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 

The Following User Says Thank You to noobmonkey For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 04:00.