Library Host audio OSX - python

Currently running a project in python which create a bunch of midi files, then map them to the OSX Host audio unit.
We've been using pyau, which worked fined with some library, but won't work now with kontakt5 and library like Shevannay (also not maintained since along time ago).
I've been over github, the python page music, google over the last week, to find a project up to date, that would fill our need (read midi file, create an host, load vst and presets and export it in any audio format).
If the library isn't in python that doesn't matter, our python script are writting midi file, so i'm okay to do read and map it to a host in any other language.
But all answer i could get were rewritting an host in c++ using juce, I don't think i actually need to writte my own code for that, they are probably people that have done that in a better way that i could do it.

Related

Creating executable Python scripts for wider audiences

I have read several posts regarding creating .exe files from Python scripts using tools like cx_freeze or pyinstaller and read a few articles which basically admit to having the same issues as the posts do - namely, the .exe files are simply too large (sometimes in the hundreds of MB). I have tried this myself on a script and simply because libraries like Numpy and Pandas were packaged into it, the executable became massive.
This is a bit of real world scenario so I am taking a shot here at asking about this but is there no way to create solutions for teams who do NOT have coding experience? The only options I can think of are:
Require all users to have Python and the related libraries installed on their systems and train them in running the scripts.
Perhaps push the script to a cloud service and run the script from there (though this may be an issue when it needs to connect to inhouse databases and other source systems).
Accept the size of the .exe file and save it on shared drives and go for a lunch break every time you need to run it.

Thoroughly cofused about using .doc APIs

Let me start off by saying my python knowledge is beginner-to-intermediate level, and I recently started using the language again after a long time.
The Goal:
This morning I came across a bunch of word documents I wanted to convert and concatenate to PDF files, with 2 .doc files creating one PDF.
seemed like a fairly trivial task, so I figured I'd try to learn how to do it in python.
concatenating PDFs wasn't too bad, I found PyPDF2 and managed to write a script that did just that.
But 7 hours later, after countless scripts with broken dependencies- I still can't find a way to automate the doc-pdf conversion.
The Problem(s):
every script I found either:
uses python-docx (my documents are word 2003 .docs)
uses unoconv bridge (which I installed along with OpenOffice, then searched around for documentation but found none- thus I have no idea how to call from a python script or the shell. I saw one example for this but it keeps throwing errors)
uses win32com or win32com.client or pywin32 or somesuch.
I ran into numerous issues with these- installed one but couldn't import it from code (as happened to the guy here), now I can't even find them with pip. searched for documentation for them (are they modules or classes? I have no idea) and found practically nothing that I could understand, beyond that they're connected to ActivePython. (which is apparantly a superset of Python with more capabilities?).
Uses comtypes, which I installed but was unable to use/import either for some reason (maybe I'm using pip wrong somehow?)
I know my question is hardly focused but honestly by now my brain is fried from information overload. any simplifications for a noob would be more than welcome.
TL;DR:
assuming no knowledge of COM stuff and little experience with any external frameworks:
what would I have to do to convert Word 2003 .doc files to .pdf files? I'm running python3.5.1 32-bit on a Windows 10 64-bit machine.
where can I learn more about accessing other software APIs from python? are there big prerequisites for this stuff like knowing how the OS works on a lower level?
Thanks!
From my experience, converting between the various office formats is best done outside of python. With the subprocess module, you can call the external command
soffice --convert-to pdf file.doc --headless
where soffice is the command that comes with LibreOffice.

No download module to manipulate sound with MP3 in Python?

I'm looking to make an audio editor using Python for a project in which I'm not allowed to use modules that need be downloaded (I can only do a simple import ).
I want to be able to have users upload a file (preferably in mp3 or some other common format for all operating systems) and be able to play back and edit it. I also need to write out a mp3 file with the new audio.
Would this be feasible in Python 2.7 without outside modules?
EDIT: This will be hosted online if that makes any difference.
Would any of these audio modules help?
audioop is a built-in module to manipulate raw audio data. It requires a format such as .WAV but you could either convert that separately or in the program.
If you want to simply upload wav files to be used with audioop, consider looking at the wave module.

How to run a Python script in something other than cmd?

I have written a program. I don't know if it is important how it is written but you can find it here: http://pastebin.com/Z3ZvVPV8 Basically, it asks you to assign values to variables and will perform calculations depending on what variables you chose, and prints the answer.
I would like to know how I can make the program run in a window other than cmd (I am using Windows Vista 32bit). I don't need much at all in terms of GUI, just a window that is a bit more user friendly/easier to look at when they are using the program.
EDIT: To those suggesting using IDLE, while that would work for me, if others want to use the program they would have to download it, so I was hoping for a way for that not to happen.
Python comes with a sort of default GUI package TkInter you can use it.
Also there is a lot of other GUI packages available.
The Python standard library offers a lot of ways to implemt simple (but also rather complex) GUIs. I'd like to point you at the documentation of TK (tool kit for graphical interfaces) http://docs.python.org/library/tk.html where you will find also some useful example of use.
Py2Exe is a viable option if you really don't need a gui. This will make it run and look like a command prompt, but it will be an .exe file. Here is a quick quote from thier page: "py2exe is a Python Distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation."
Another alternative is to get Portable Python. Here is a quote from thier webpage: "Portable Python is a Python® programming language preconfigured to run directly from any USB storage device, enabling you to have, at any time, a portable programming environment. Just download it, extract to your portable storage device or hard drive and in 10 minutes you are ready to create your next Python® application." After packaging the portable python and your .py or .pyc file then create a .bat file that runs the portable python "Python-Portable.exe" with the correct command line parameters for loading your script. Be sure to use relative paths in the batch file in case they are running it from a flash drive, or something other than the same location as you.
NOTE: This is really not a good way to do this as thier download page states: "Installed size: based on selected packages, between 49MB and 480MB". Also be sure to read the the current Python Software Foundation License, as that is what Portable Python is released under, and it may or may not be legal to package it in a closed source project. I haven't really looked at the license myself to be able to tell you. If you are releasing it as open source, then there would not be an issue though. As a quick side note, if you need that .bat file to be a .exe file then you can use a .bat to .exe converter battoexe.com is one. This is really going the long way about doing the whole thing, but it is an option.
Sources:
Working with Python on and off for 7 years now, a lot that using a portable version on a flash drive, and also dealing with Batch files much longer.

Quick way to validate and convert Audio Files with Python?

For a website i am developing in django i need users to be able to upload .wav or .aif files. I, of course, have to make sure these files really are what they pretend to be - audiofiles. The files then are provided on the webpage, where i need them to be either .ogg or .mp3
While searching for a solution i stumbled across some fearsome possibilities, like using ctypes to handle external libraries. I also found, of course, PyMedia, which i cannot use because i develop on MacOSX. And the python audio tools provide a lot of functionality i do not need.
So far i can see a few possibilities that would satisfy me and are within reach of my programming capabilities:
1 Get PyMedia to run on MacOSX
2 Find a way to use some modules of the python audio tools without the need to use libcdio
3 use python subprocess to run the command line tools of the converters
As i have used none of those tools yet, i can't tell which would possibly be the quickest way to solve my problem. If you Python-Audio-Gurus are out there, could you please share some thoughts? Or maybe you even have a fantastic 1-step-to-happiness solution?
Not strictly a pythonic answer, but perhaps take a look at sox which is a simple command line audio file converter. It can do resampling of audio files for you as well.
Check out the command line options of sox for details. This will of course involve calling the external program using the subprocess module(or other method).

Categories

Resources