Posts

Showing posts with the label music

Midi musical intrument controllers and synthesizers with python and pygame

Image
Musical Instrument Digital Interface (Midi), is for letting digital musical instruments talk to each other in 'real time'. It came from the early 80s, and is still used today. The main idea is that rather than sending audio data, it sends small control messages. This is great for fast real time low bandwidth communication. I'm going to show in all the different ways midi can be used with python/pygame with three separate programs, and how to set up a virtual synth (I've included instructions for Win, Mac, and Linux). Full article is available for patrons first as an "early access" before it becomes available to all in a month:  https://www.patreon.com/posts/midi-music-pygame-python-43826303 You can support my pygame development and read my development log at: https://www.patreon.com/pygame

pygame 2 update - the examples all work

Image
  🎮👾👽🎮👾👽🎮👾👽🎮👾👽 examples/ chimp.py works 👽🎮👾👽🎮👾👽🎮👾👽🎮👾 That's a nice milestone for pygame 2 development. (and also, now these examples also work...     python -m pygame.examples.aliens     python -m pygame.examples.scroll ) I'm pretty sure all the examples are now working with SDL2/pygame 2. New SDL2 functionality. Also we have some new SDL2 functionality exposed     (experimentally, the APIs are not done yet). Multitouch, and AudioDevice, along with an example of recording audio. @dlon has been fixing a number of bugs(implementing key repeat, fixing unicode issues) and also prototyped some Window/Renderer classes (using ctypes and python). The new events are done in a backwards compatible way, so that games using them with pygame 1/SDL1 will still work. You just won't get the events. if event.type == pg.AUDIODEVICEADDED:     prin...

pygame artist in residence grant

Image
An artist residency usually works something like; a person spends some time in either a gallery making something to present or in a music club doing a weekly spot. Artist in residence. The first "pygame artist in residence" grant will be for a small amount of money (€512). It is for someone who is already doing stuff with pygame or python in their arts practice. There will be a little thumbnail on the website linking towards an artist statement/patreon page/blog or some such. The residency won't be in a physical space. It lasts for a month, from October 1st - November 1st. At the end of the month the website 'exhibition' will take the form of a small update from the artist — in whatever form that takes . If you'd like to apply(or nominate someone) please write something short with a link about the arts practice and how python or pygame is used in it. Email: residency@pygame.org Applications close: September 15th. Announced: October 1s...

Drawing sound (as a waveform in pygame).

Image
I recently gave an example of pygame sound generation examples , and a few people asked for more. So... here we go! There's an infinite number of ways to visualize sound. A classic way is to draw it as a waveform . Sound samples drawn as a Waveform. Scaled into a 320x200 sized Surface. A sound could be made up of 44100 samples per second. Where each sample is often a 16 bit number (or 8bit or a 32bit floating point). Python comes with a built in array for efficiently storing numbers. We can store samples in there, with integers between -32768 and 32768. This is a signed 16bit(2 byte) number. Two to the power of 16 is 65536, and if we divide that by two we see the minimum and maximum value that can hold. pow(2, 16) / 2 == 32768. Below is the annotated code, also with an example of an array of samples representing a square wave. We loop over the samples and draw a line from the previous sample to the current one. 0 to 1, 1 to 2, 2 to 3, ... N-1 to N. You can also fin...

Sound generation pygame examples.

Here's a few sound generation examples with pygame (and no numpy/scipy). If there's interest I'll expand this into a bigger example? Let me know. All the basics for making a music program (sampler/synth). some sample rate conversion, bit rate conversion tone generation using generators (square wave) python arrays used as buffers for pygame.Sound (zero copy). """ Some examples for generating and converting sounds for pygame. Python 2.7, 3.6 Shows: - a simple 'square wave' generated - resampling sample rates (eg, 8363 to 44100) - using built in python array for making pygame.Sound samples. - samples at different bit sizes - converting from signed 8 to signed 16bit - how initializing the mixer changes what samples Sound needs. - Using the python stdlib audioop.ratecv for sample rate conversion. Square Wave https://en.wikipedia.org/wiki/Square_wave MOD (file format) https://en.wikipedia.or...

Welcome to your new NSA partner network. Tech art in Berlin.

Image
Whilst walking around the Afterglow art hack day opening in Berlin, my phone buzzed as I had received a text message.  Opening up my phone I saw this: "Welcome to your new NSA partner network." I immediately had a scary thought.  "Had someone hacked into my phone?" My next thought was "oh, someone is hacking the mobile networks".  "Damn, I forgot to turn my phone off like I usually do before coming to hacker events". My phone didn't have service to either of the networks it usually connects to, so someone was definitely jamming the phone systems. This message was a very impressive piece of tech art indeed.  It made me think, and feel something. We are starting an EU/UK tech online magazine . Want to know when it is released? Email notify me when it's ready Want to be interviewed? Rest your head against the speaker. Part of the art hack day. ...

Serial and pixels for breakfast. Arduino + pygame.

Image
Taking a byte of bits of Serial, along with Green screen with Sam, pygame, and an Arduino hooked up to a light sensor and a motor thing. Coffee too?  Naturally. Where do we begin?  At the end of course.  A video of the result... The arduino code #include < Servo .h> Servo myservo; int potpin = 0; int val; void setup () {    Serial . begin (9600);   myservo. attach (9); }    void loop () {   val =  analogRead (potpin);    Serial . println (val);   val =  map (val, 62, 540, 0, 179);   myservo. write (val);    delay (15); } python pygame code Extended the " green eggs and ham" code I made recently to read serial data from the Arduino, and paint the screen different shades of green, whilst also making some silly sounds depending on the value read from the light sensor. import os import pygame import serial # guessing serial ports nam...

Pokket mixer. A sound mixer from Berlin.

Image
pokket mixer I went to the big market at the Berlin park today, and saw this little sound mixer there. This dude and his girlfriend who were at the stall make them! They are his design too. Really cool buying electronics from the people who make them. Did I mention I like buying small things that can fit in my pocket, and in my carry-on luggage? It's passive - so it does not need to be powered. It's also very small. Seems to work quite well. The eq seems to work ok. It has the normal Hi, Mid, Lo for each of the two channels. The sound quality seems pretty good (even when going out to high quality studio speakers). I've bought more expensive mixers with worse audio quality.

pygame.midi -- midi in, and midi out.

Image
I started adding more midi support to pygame . Pygame can already play midi files, however it can not get midi input, or send midi output to devices. Nicholas played around with some midi stuff in our eye stabs computer game... where it turned notes from a real guitar using pitch detection into midi events. This experiment used portmidi, and it seems to work ok in a cross platform manner. I hooked up my USB midi controller, and am able to get midi events! I've also added some code which converts the midi events into pygame events, and posts them to the normal pygame event queue. This simplifies things for people already used to handling events with pygame (like mouse, keyboard, and joystick events). I can also get it to write to midi outputs, but haven't really got a use for that yet. However I would like to hook it up to my casio keyboard to get some retro sounds out of it... but I have no midi output converter anymore. It is possible to get USB->midi converters fair...

I Am A Drum Machine

Image
Here's a song I made the other night - I thought some of you might find it funny. http://rene.f0o.com/~rene/stuff/I-am-a-drum-machine.mp3 If you just want to play it in your browser, there is a flash based player here with it: http://www.pretendpaper.com Written by a Melbourne web developer . Available for your projects - php, mysql, e commerce, javascript, CMS, css, flash, actionscript, python, games, postgresql, xml.