473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

would it be feasable to write python DJing software

Hi, I'm thinking about writing a system for DJing in python, but I'm
not sure if Python is fast enough to handle the realtime audio needed
for DJing, could a guru shed some light on this subject and tell me if
this is doable or if I'm out of my fscking mind?

Feb 3 '06 #1
19 1518
Levi Campbell wrote:
Hi, I'm thinking about writing a system for DJing in python, but I'm
not sure if Python is fast enough to handle the realtime audio needed
for DJing, could a guru shed some light on this subject and tell me if
this is doable or if I'm out of my fscking mind?


What do you mean by DJing? Queueing and playing audio files? If so,
python should work fine. Check out the PyMedia library for
playing/mixing audio with python.

-Farshid
Feb 3 '06 #2
Levi Campbell wrote:
Hi, I'm thinking about writing a system for DJing in python, but I'm
not sure if Python is fast enough to handle the realtime audio needed
for DJing, could a guru shed some light on this subject and tell me if
this is doable or if I'm out of my fscking mind?


Any and all mixing would probably happen in some sort of multimedia
library written in C (it would be both clumsy to program and slow to
execute if the calculations of raw samples/bytes were done in python) so
there shouldn't be a noticable performance hit.
Feb 3 '06 #3
On Fri, 03 Feb 2006 02:35:56 +0100
Ivan Voras <ivoras@__-fer.hr-__> wrote:
Levi Campbell wrote:
Hi, I'm thinking about writing a system for DJing in
python, but I'm not sure if Python is fast enough to
handle the realtime audio needed for DJing


Any and all mixing would probably happen in some sort of
multimedia library written in C


Of which more than one exists. You may have some interest in
PyMedia, PyGame (SDL), pyogg, pyvorbis packages.

You might want to try googling for "Python audio libraries",
that appears to turn up some other results.

Note that pyogg/pyvorbis will also give you access to
the embedded metadata in Ogg files, which sounds like it
might be useful in your application.

Cheers,
Terry

--
Terry Hancock (ha*****@AnansiSpaceworks.com)
Anansi Spaceworks http://www.AnansiSpaceworks.com

Feb 3 '06 #4
Levi Campbell wrote:
Any and all mixing would probably happen in some sort of multimedia
library written in C (it would be both clumsy to program and slow to
execute if the calculations of raw samples/bytes were done in python) so
there shouldn't be a noticable performance hit.


Actually, manipulating and mixing audio samples can be both fast and
elegant, in Python, if you use Numeric or a similar library.

-Sw.

Feb 3 '06 #5
si**********@gmail.com wrote:
Actually, manipulating and mixing audio samples can be both fast and
elegant, in Python, if you use Numeric or a similar library.


.... at which point you're actually doing it in C, not pure python... :)
Feb 3 '06 #6

Ivan Voras wrote:
si**********@gmail.com wrote:
Actually, manipulating and mixing audio samples can be both fast and
elegant, in Python, if you use Numeric or a similar library.


... at which point you're actually doing it in C, not pure python... :)


Only in as much as doing anything in Python is *really* doing it in C,
surely ?

Come to that, you're **really** doing it in machine code...

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

Feb 3 '06 #7
Fuzzyman wrote:
Only in as much as doing anything in Python is *really* doing it in C,
surely ?

Come to that, you're **really** doing it in machine code...


I've yet to see someone calling

if a == '5':
print "it's 5"

machine code. It's the distinction on which level the program's logic is
implemented, not at which level it's executed.
Feb 3 '06 #8
Ivan Voras wrote:
Come to that, you're **really** doing it in machine code...


I've yet to see someone calling

if a == '5':
print "it's 5"

machine code. It's the distinction on which level the program's logic is
implemented, not at which level it's executed.


uhuh? so why did you just argue that

if foo.bar():
bar.aba()

means "doing it in C" if bar and aba happens to be parts of an extension
library ?

</F>

Feb 3 '06 #9
On 2006-02-03, Ivan Voras <ivoras@__yahoo__.com_> wrote:
si**********@gmail.com wrote:
Actually, manipulating and mixing audio samples can be both fast and
elegant, in Python, if you use Numeric or a similar library.


... at which point you're actually doing it in C, not pure python... :)


If that's the way you want to look at it, there is nothing that
can be done in pure python. Both the built-ins and the basic
operators and sematics are implimented in C. Unless you're
running Jython on a platform that has a hardware JVM, I
suppose. But noboby in this discussion is doing that.

--
Grant Edwards grante Yow! Should I get
at locked in the PRINCICAL'S
visi.com OFFICE today -- or have
a VASECTOMY??
Feb 3 '06 #10
On 2006-02-03, Fuzzyman <fu******@gmail.com> wrote:
Come to that, you're **really** doing it in machine code...


And probably not the machine code emitted by the assembler but
rather the actual micro-code that's implemented in hardware
that's running a program that implements the VM for the machine
code emitted by the assemblers.

Hell, from the Python point of view it might as well be
tortoises all the way down.

--
Grant Edwards grante Yow! Dehydrated EGGS are
at STREWN across ROULETTE
visi.com TABLES...
Feb 3 '06 #11
> If that's the way you want to look at it, there is nothing that
can be done in pure python. Both the built-ins and the basic
operators and sematics are implimented in C.


What makes python a powerful programming language? It's the fact that
it bundles up all sorts of c-code into a nice easy to use language.
When you write _any_ python, you are taking a peice of c here, a piece
of c here, and when you import a "pure python" module, you're really
just importing more c, because it's all being built from c.

What makes a builtin faster? It's the fact that there's less work to
be done before it's called. As more work needs to get done to find the
builtins that make it possible to run, execution time increases. Plain
and simple.

So, to answer the original posters question, Use python to peice
together the things you need. You're development time will be fast,
and you will probably see some good results.


--
Andrew Gwozdziewycz <ap****@gmail.com>
http://ihadagreatview.org
http://plasticandroid.org
Feb 3 '06 #12
On Fri, 3 Feb 2006, Ivan Voras wrote:
Levi Campbell wrote:
Hi, I'm thinking about writing a system for DJing in python, but I'm
not sure if Python is fast enough to handle the realtime audio needed
for DJing, could a guru shed some light on this subject and tell me if
this is doable or if I'm out of my fscking mind?

Perhaps surprisingly, it is:

http://www.python.org/pycon/dc2004/papers/6/

At least, you can certainly mix in realtime in pure python, and can
probably manage some level of effects processing. I'd be skeptical about
decoding MP3 in realtime, but then you don't want to write your own MP3
decoder anyway, and the existing ones you might reuse are all native code.
Any and all mixing would probably happen in some sort of multimedia
library written in C (it would be both clumsy to program and slow to
execute if the calculations of raw samples/bytes were done in python)


Clumsy? Clumsier than C? No, python isn't as good with binary data as it
is with text or objects, but on the whole program scale, it's still miles
ahead of C.

My advice would be to tackle the task in the same way you'd tackle any
other: write it in pure python, then fall back to native code where it's
unavoidable. When i say 'pure python', i don't mean 'not using any native
modules at all', obviously - if someone's written an MP3 decoder, don't
eschew it because it happens to be in C. Also, bear in mind that resorting
to native code doesn't automatically mean writing in C - you can start
doing stuff like moving from representing buffers as lists of ints to
using NumPy arrays, using the functions in the standard audioop module,
whatever; if that's not fast enough, rewrite chunks of the code in pyrex
(a derivative of python that can be compiled to native code, via
translation to C); if it's still not fast enough, go to C.

Oh, and before you start going native, try running your program under
psyco.

tom

--
Throw bricks at lawyers if you can!
Feb 3 '06 #13
Grant Edwards wrote:
On 2006-02-03, Ivan Voras <ivoras@__yahoo__.com_> wrote:
si**********@gmail.com wrote:
Actually, manipulating and mixing audio samples can be both fast and
elegant, in Python, if you use Numeric or a similar library.


... at which point you're actually doing it in C, not pure python... :)


If that's the way you want to look at it, there is nothing that
can be done in pure python.


I think people who say that deliberately misunderstand the point. Python
is suitable for some things, not for others. So is C.
Feb 3 '06 #14
On Fri, 03 Feb 2006 20:03:01 +0100
Ivan Voras <iv****@fer.hr> wrote:
Grant Edwards wrote:
On 2006-02-03, Ivan Voras <ivoras@__yahoo__.com_> wrote:
si**********@gmail.com wrote:

Actually, manipulating and mixing audio samples can be

both fast and >>elegant, in Python, if you use Numeric or
a similar library. >
... at which point you're actually doing it in C, not

pure python... :)

If that's the way you want to look at it, there is
nothing that can be done in pure python.


I think people who say that deliberately misunderstand the
point. Python is suitable for some things, not for
others. So is C. --


To me, "doing it in C" implies that I must write some C
code.

In this case, that won't be required at all. Everything the
OP wants to do can be done exclusively by writing Python
code. He will, of course, be *using* some extension
libraries which might in turn have been written in C (or
Fortran, assembly language, or ADA for that matter -- but
practically speaking, C).

This will be true whether he uses PyMedia, PyGame, Numeric
or all three.

Indeed, as an implementation matter only the "glue code"
will be interpreted in Python -- but the OP will not have to
write anything but such "glue code".

For me, who no longer writes *any* C code, not having to
write the C code is a big win. And I think this is the PoV
relevant to the OP.

Cheers,
Terry
--
Terry Hancock (ha*****@AnansiSpaceworks.com)
Anansi Spaceworks http://www.AnansiSpaceworks.com

Feb 3 '06 #15
On 2006-02-03, Ivan Voras <iv****@fer.hr> wrote:
Actually, manipulating and mixing audio samples can be both fast and
elegant, in Python, if you use Numeric or a similar library.

... at which point you're actually doing it in C, not pure python... :)


If that's the way you want to look at it, there is nothing that
can be done in pure python.


I think people who say that deliberately misunderstand the
point. Python is suitable for some things, not for others. So
is C.


People who say what?

--
Grant Edwards grante Yow! Do you need
at any MOUTH-TO-MOUTH
visi.com resuscitation?
Feb 3 '06 #16
Terry Hancock wrote:
To me, "doing it in C" implies that I must write some C
code.
Ok, perhaps it is a bit imprecise :)
In this case, that won't be required at all. Everything the
OP wants to do can be done exclusively by writing Python
code. He will, of course, be *using* some extension
libraries which might in turn have been written in C (or
Fortran, assembly language, or ADA for that matter -- but
practically speaking, C).

This will be true whether he uses PyMedia, PyGame, Numeric
or all three.


This, of course, is what I am talking about. Python is a great glue
language, but not exactly suitable for lots of bit twiddling or DSP by
itself (itself=only with modules from the standard distribution) :)

Feb 3 '06 #17
Fredrik Lundh wrote:

uhuh? so why did you just argue that

if foo.bar():
bar.aba()

means "doing it in C" if bar and aba happens to be parts of an extension
library ?


Because "bar and aba happen to be parts of extension library" :)
Feb 4 '06 #18
Ivan Voras wrote:
Because "bar and aba happen to be parts of extension library" :)


To end this disussion: I meant "doing it in C" as a colloquial
expression, not a technical one. The expression holds true for every
case where a function/class/module/etc is implemented in a lower-level
language, and "C" was used only as an example.
Feb 4 '06 #19

Ivan Voras wrote:
Ivan Voras wrote:
Because "bar and aba happen to be parts of extension library" :)


To end this disussion: I meant "doing it in C" as a colloquial
expression, not a technical one. The expression holds true for every
case where a function/class/module/etc is implemented in a lower-level
language, and "C" was used only as an example.


I think the point we were trying to make, is that even in 'colloquial
terms' there is *no difference* between using a part of the standard
library (e.g. the builtin module md5) and a third party extension
module written in C.

All the logic you actually write is in pure python.

If you write *your own extension module* in C, then you could rightly
be described as doing it in C.

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

Feb 6 '06 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Irmen de Jong | last post by:
QOTW: "Confronting the Martellibot is like flirting with an encyclopedia, I'd rather not do it myself, but I respect those who do, because it produces knowledge." -- Anton...
0
by: Irmen de Jong | last post by:
QOTW: "What can I do with Python that I can't do with C#? You can go home on time at the end of the day." -- Daniel Klein "Python lends itself to playing with it and to discussing the merits of...
33
by: Nick Evans | last post by:
Hello there, I have been on and off learning to code (with python being the second language I have worked on after a bit of BASIC). What I really want to know is, if you are going to actually...
0
by: Cameron Laird | last post by:
QOTW: "The advantage of using slices to extract a single element is that it avoids IndexErrors for empty lists." Raymond Hettinger http://groups.google.com/groups?th=44bd04fe85d02c19 "Usually...
5
by: gel | last post by:
Hi I have written a python client server app that keeps an eye on processes starting and ending on a client and makes decision on what to do based on information from the server end. I want to...
23
by: gord | last post by:
As a complete novice in the study of Python, I am asking myself where this language is superior or better suited than others. For example, all I see in the tutorials are lots of examples of list...
6
by: gel | last post by:
I would like to write some data recovery software as a learning thing. The sort of thing that you would use to recover data from a currupt HDD or floppy etc. I would like to be pointed in the...
9
by: king kikapu | last post by:
Hi to all folks here, i just bought a book and started reading about this language. I want to ask what options do we have to deploy a python program to users that do not have the labguage...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.