I've had a go at putting together a P.O.V (persistence of vision) font creator to create fonts for an Arduino project i'm working on.
If you're not sure what P.O.V. is (I didn't know until two days ago), its basically a way of creating the illusion of a two dimensional image, perhaps of LED's for example, by using a single row of LED's moving rapidly - think, LEDs on a fan spinning round creating the illusion of lettering or images.
This code is for text 16 'pixels' high. Before using, a 16pt Arial Bold font in the data directory needs to be created - make sure smoothing is off when you create the font. You could use different fonts but I haven't tested it.
This code makes arrays of 16bit numbers that can be processed in Arduino etc to switch LED's on or off. But it can also save to file strings of the binary data
Just comment out the parts you don't want in your file.
void draw(){ if (ascii < 128){ letter = (char(ascii)+""); background(255); fill(0); text(letter,20,20); drawbig(); ascii++; } else { output.flush(); // Writes the remaining data to the file output.close(); // Finishes the file exit(); // Stops the program } }
void drawbig(){ int letterheight = 16; int letterwidth = int(textWidth(letter)); String[] pov = new String[letterwidth]; int[] povnums = new int[letterwidth]; for (int i = 0; i<letterwidth; i++){ String povline = ""; //line of 0s and 1s for (int j = 0; j<letterheight; j++){ color pixelcol=get(20+i,22-j); //you may need to change the 22 as the font dips below the base line for descenders if (int(brightness(pixelcol)) > 150){ povline = povline+"0"; } else{ povline = povline+"1"; }
fill(pixelcol); rect (20+(i*10),280-(j*10),10,10); } pov[i] = povline; povnums[i] = unbinary(povline); } for (int i = 0; i<pov.length; i++){output.println(pov[i]);}; // prints binary display output.println();
output.print("'"+letter+"' = {"); //the next bit prints the number array output.print(povnums[0]); for (int i = 1; i<pov.length; i++){output.print(", "+povnums[i]);}; output.print(" };");
What does this mean? Does it mean there's a problem with line 22 in setup() of the pde file?
I have preloaded the font and image as indicated in the documentation. I also use a txt file to loadStrings but i didn't think this needs to be preloaded. Here are the preload comments:
Using the alternet library for networking I can't sent a string from client to server or vice versa if the string contains special characters such as umlauts. There are a number of places that suggest converting the string to a byte array and then converting back to a string afterwards. I have tried to find examples of this but I can't seem to find any that work for me.
But it never sends as it doesn't seem to recognise the ("UTF-8") section of the code. When I remove the catch() it always says
UnsupportedEncodingException.
How can I convert a UTF8 string to byte array and send to the server?
How does it get reconverted afterwards? The server will sent to all the clients afterwards so I presume it gets reconverted when returned to the clients.
I have included in my code the mousewheel listener event from the Processing wiki
addMouseWheelListener
(
new java.awt.event.MouseWheelListener()
{
public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt)
{
mouseWheel(evt.getWheelRotation());
}
}
);
The odd thing is, when I use the mouse wheel it seems to change my font settings. I have several fonts loaded for different parts of my application and it swaps or changes the fonts round occasionally and randomly when I use the mouse wheel. How strange.
I've looked through my code and there is nothing obvious as to why this is happening. It only happens occasionally and for no clear reason. Does anyone know why this is?
If it is an unsolvable problem, does anyone know an alternative way of using the mouse wheel?
I'm totally new to networking, only read the library docs and played a bit with some of the examples.
I am setting up a collaborative text editor with 32 computers.
A client computer writes a string to the server after a keyPressed event.
The server then writes to all the other clients.
What I wanted to know is, can the server react to a clients update immediately? Like with a network listener?
What i'm worried about is the possibility of two clients sending a message almost simultaneously.
If the server will only check for messages using available() inside draw(), then there's much more likelihood that more than one message will have been received from multiple clients. If this is the only way, how would I send multiple sets of data to the clients?
I know the clients use clientEvent() to listen for a network update.
Is there an equivalent for the server? It seems that serverEvent() only listens for when a client joins the network, not when data is sent.
Any help appreciated. If anyone has any experience of this kind of network situation any tips gratefully received.
I'm not asking for anyone to write all my code for me, just to give a few pointers.
I am just starting to use supercollider and processing with p5_sc library and I am having trouble creating multiple buffers. I want to play several sound samples using different buffers but I can only create 1 buffer which must be named "playbuf_1"
My porcessing code is:
import oscP5.*; import netP5.*;
import supercollider.*;
Buffer buffer;
void setup () { Buffer buffer = new Buffer(2); buffer.read("C:\\Voices/voice1s.wav"); Synth synth = new Synth("playbuf_1"); synth.set("bufnum", buffer.index); synth.create(); }
The strange thing is when I rename the buffer in both SC and Processing to anything else (e.g. playbuf_2) the
buffer will not play in SC. I get an error post saying:
*** ERROR: SynthDef playbuf_2 not found FAILURE /s_new SynthDef not found FAILURE /n_set Node not found
Why is this?
If I want to use multiple samples I assume I will need more than the one buffer. How can I rename the buffer to have multiples samples playing?
Hi,
I have been using this class code to access the FreeTTS API and can access some of the features of voice manipulation. I would like to save the synth stream to file but I'm struggling to do this.
I know I have all the FreeTTS files and Mbrola correctly installed as I can hear the speech synth working.
But when I try to save to file by using SingleFileAudioPlayer I cant seem to find the wave file - it doesn't seem to be saving it.
Here is the code, I have highlighted the suspect code in red:
if (voice == null) { System.err.println( "Cannot find a voice named " + voiceName + ". Please specify a different voice."); System.exit(1); } voice.allocate(); }
void mluv(String _a){
if(_a==null){ _a= "nothing"; } voice.speak(_a);
}
void exit(){ voice.deallocate(); } }
The main code for the programme is then
Basnik verlaine ;
void setup(){ System.setProperty("mbrola.base","C:\\mbrola"); verlaine = new Basnik("mbrola_us3",20.0,20.0); verlaine.mluv("I'm finding this difficult") ; }
Why is the file not saving? I have tried various permutations of the file name C:\max, C:\max.wav etc..
Please help!
Hi, I have been messing with processing for 3 days now. Very new to programming...
I am trying to work with Roborealm robotic vision software.
Here's how I hoped it works...
Processing accesses a text file that includes a string array of data in multiples of 12 numbers - each set of 12 providing data for each object identified by Roborealm - the length of this string is variable depending on how many objects the vision software identifies
At setup (), 20 'Circle' objects are created to place data in.
A Timer class creates a loop every 6400 ms.
In draw(), at the end of the timer loop, data from the file is added to the Circles objects, to then be used to create imagery and sound
Problem -
I keep getting
The constructor 'Timer' is unidentified, with reference to the line in setup () , timer = new Timer(6400)
What am I doing wrong?
As far as I can tell the Timer class seems to be constructed properly?
Please help!
Here is the code
Circles [] circles;
Timer timer;
String numbers= join(loadStrings("test2.txt")," ");//loads in file and joins strings into one
int[] nums = int(split(numbers, " "));//converts string to integer array
void setup() {
size (640,480);
timer = new Timer(6400);//starts a timing loop
timer.start();
for (int i = 0; i < 20; i++) {
//initialise 20 circle objects
circles [i] = new Circles(0,0,0,0,0,0,0);
}
}
void draw() {
background();
if (timer.isfinished());//end of the timer loop
{
for (int i = 0; i < (nums[].length/12); i++){ //put data into active objects
circles[i].Xpos = nums[i*12];
circles[i].Ypos = nums[i*12+1];
circles[i].Rad = nums[i*12+2];
circles[i].Standev = nums[i*12+3];
circles[i].ColR = nums[i*12+4];
circles[i].ColG = nums[i*12+5];
circles[i].ColB = nums[i*12+6];
}
for (int i = nums[].length/12; i < 20; i++){//put zero data into inactive objects (see Circles class / deactivate
circles[i].deactivate;
}
timer.start(); //restart the timer
}
}
//define Circles class
class Circles {
int xpos;
int ypos;
int radius;
int standev; //standard deviation of circle colour;
int colourr; //mean red colour of circle
int colourg; // '' green
int colourb; // '' blue
Timer timer;
//Circles Constructor
Circles(int Xpos, int Ypos, int Rad, int Standev, int ColR, int ColG, int ColB)
{
xpos = Xpos;
ypos = Ypos;
radius = Rad;
standev = Standev;
colourr = ColR;
colourg = ColG;
colourb = ColB;
}
// Starting the timer
void start() {
// When the timer starts it stores the current time in milliseconds.
savedTime = millis();
}
// The function isFinished() returns true if 6,400 ms have passed.
boolean isFinished() {
// Check how much time has passed
int passedTime = millis()- savedTime;
if (passedTime > totalTime) {
return true;
} else {
return false;
}