I have been trying to determine how to create audio from pixels. There are many near-answers for questions, but very little useful code.
This is an example using the CreateSample method in Minim. It is derived from examples on the Minim site. It fails after a certain number of plays, probably due to the same problems discussed on this page:
http://code.compartmental.net/tools/minim/manual-audiosample/ The solution was to make a FilePLayer player... but it doesn't work for samples.
/// this is intended to mimic finding pixels on an image and sending them to an audio output for other uses
import ddf.minim.*;
import ddf.minim.signals.*;
// we must import this package to create an AudioFormat object
import javax.sound.sampled.*;
Minim minim;
AudioSample wave;
// we'll use a sine wave signal to generate a buffer of floats
// that will be used to create an AudioSample.
SineWave sine;
// when we create a sample we need to provide an AudioFormat so
// the sound will be played back correctly.
AudioFormat format = new AudioFormat( 44100, // sample rate
16, // sample size in bits
1, // channels
true, // signed
true // bigEndian
);
// we'll make a MONO sample, but there is also a version
// of createSample that you can pass two float arrays to:
// which will be used for the left and right channels
// of a stereo sample.
float[] samples = new float[1024*8];
void setup()
{
size(512, 200, P3D);
// always start Minim before you do anything with it
minim = new Minim(this);
// make a sine wave!
sine = new SineWave( 220, // frequency in Hz
0.5, // amplitude
44100 // sample rate
);
/// array should mimic a line of pixels being read by whatever algorithm I use.
for (int i=0;i<(1024*8);i++){
samples[i]=random(-200,200);
}
// finally, create the AudioSample
wave = minim.createSample( samples, // the samples
format, // the format
1024 // the output buffer size
);
frameRate(10);
minim.debugOn();
}
void draw()
{
background(0);
/// array should mimic a line of pixels being read by whatever algorithm I use.
for (int i=0;i<(1024*8);i++){
samples[i]=random(-2,2);
}
// create the AudioSample
wave = minim.createSample( samples, // the samples
// always close Minim audio classes when you are done with them
wave.close();
minim.stop();
super.stop();
}
I know there may be better ways to do this, but the idea of creating an audio buffer from an array that is constantly changing as it is read from pixels would be incredibly useful (I've spent weeks trying to find a solution for doing this with pure data and chuck, but this solution would be incredibly useful) This particular version has a tendency to go silent, and I think it is a buffer issue since there is no real way of clearing an audio sample.
Could someone help me with this, please?
I've checked the following ideas but with no luck (don't understand the code, or solutions never posted)
http://processing.org/discourse/beta/num_1200904097.html ... It might work, but it isn't commented very well, and I have no idea how the class MuzikMaker works... (it's also from 2008, so I don't know if it was ever resolved, or if other, better solutions exist. )
Thank you, if you can help me figure this out.
PS: I tried to incorporate an 'isPlaying' check, but those don't exist for AudioSamples...
I have some information I would like to send over OSC. It probably will never be over the width of the screen, and I can limit it's size.
It would be about 2048 or so bytes.
This is an attempt to send pixel information derived from a multitouch processing sketch to a program like PureData or ChucK, where it will (hopefully) be rendered into sound.
I know OSC has a format for sending blobs (
http://opensoundcontrol.org/book/export.html/1 ) but I have not found any examples for how to do so in Processing. I know several people have recommended NOT using this particular format as a relatively constant stream, but I may be limited in how to accomplish this for my project.
The project is to render pixels as audio. I'm hoping to use ChucK as it may provide the mechanisms for making more harmonic sounds than straight pixels to audio.
I have a project I shall be working on which will be using raw data (think pixels from an image) that will be modified slightly (to fit the 44khz audio frequency) and used to generate audio.
I am having difficulty in doing this, however. Many of the various libraries or alternative programs (minim, supercolider, chuck & pd) work on a 'create digital notes' basis after analyzing the data, but I would like to format this information as if it were a live microphone signal.
Is there a particular term I should search for? A "virtual microphone" library or another suggestion for how to do this? I keep finding 'almost' solutions but nothing really works well.
This is inspired by openframeworks code shared by James George.
I am basically trying to save frames from a video feed into an image array, and then choose how that image array will be shown.
I can get it to work, almost, but it seems that the images which I am saving are all turning out the same. I can do the same thing with opencv, but it hiccups and does not work very well.
Here is the gist of the code:
import processing.video.*;
Capture video;
int frameNumber = 0; //start at frame 1
int fBM = 60; //fBM = frameBufferMaximum
PImage img;
PImage[] frameBuffer = new PImage[fBM+1]; //store 60 frames
void setup() {
size(800, 480, P2D);
// Uses the default video input, see the reference if this causes an error
This should be fairly straight forward, but it seems all of the images are the same, current frame of video being shown. It should be generating a relative video delay with this process, but it doesn't work that way.
I've searched several forums, but cannot figure out how to get a video frame to be copied as an image for later use. It's very perplexing. Any help would be appreciated.
I have a sketch which uses the http library found here (
http://francisli.github.com/processing-http/ ) to get instagram information on popular instagram photographs. I would also like to be able to get specific information on the uploader of the photograph through another http request.
I can only find examples of single requests and am not sure how I could go about getting more specific information through another http request.