C++
For this code I used the src from pd. This lines are written in c and they create, communicate and write info to a socket. I added a ';' at the end of the string that is generated from the interaction with the keyboard. That allows to send the info to pd. the patch with netreceive has to be open in pd otherwise the socket won't be created. It was written in fc3.
#include <sys/types.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netdb.h>
#include <stdio.h>
#include <unistd.h>
#define SOCKET_ERROR -1
#define BUFSIZE 4096
int main(int argc, char **argv)
{
int sockfd, portno=3000, protocol;
struct sockaddr_in server;
struct hostent *hp;
char *hostname;
hostname = "127.0.0.1";
protocol = SOCK_STREAM;
sockfd = socket(AF_INET, protocol, 0);
if (sockfd < 0) exit(1);
server.sin_family = AF_INET;//connect socket using hostname
hp = gethostbyname(hostname);
if (hp == 0) exit(1);
memcpy((char *)&server.sin_addr, (char *)hp->h_addr, hp->h_length);
server.sin_port = htons((unsigned short)portno); //assign client port number
connect(sockfd,(struct sockaddr *) &server, sizeof (server));//connect
while (1) //now loop reading stdin and sending it to socket
{
char buf[BUFSIZE], *bp, nsent, nsend;
fgets(buf, BUFSIZE, stdin);
nsend = strlen(buf);
for (bp = buf, nsent = 0; nsent < nsend;)
{
int res = send(sockfd, buf, nsend-nsent, 0);
if (res < 0) exit(1);
send(sockfd, ";", 1, 0);
nsent += res;
bp += res;
}
}
}
htttp://onsight.id.gu.se/~alejandro/portfolio
PD midiindev what number?
Hello!
I connected my USB MAudio Midisport 2x2 and installed the proper driver. It is soundcard 3.
/proc/asound/cards:
0 [I82801DBICH4 ]: ICH - Intel 82801DB-ICH4
Intel 82801DB-ICH4 at 0xf4fff800, irq 7
1 [VirMIDI ]: VirMIDI - VirMIDI
Virtual MIDI Card 1
2 [Modem ]: ICH - Intel 82801DB-ICH4 Modem
Intel 82801DB-ICH4 Modem at 0xb400, irq 7
3 [M2x2 ]: USB-Audio - MidiSport 2x2
M-Audio MidiSport 2x2 at usb-0000:00:1d.0-1, full speed
The Ouptup of: aconnect -io:
client 0: 'System' [type=kernel]
0 'Timer '
1 'Announce '
client 72: 'Virtual Raw MIDI 1-0' [type=kernel]
0 'VirMIDI 1-0 '
client 73: 'Virtual Raw MIDI 1-1' [type=kernel]
0 'VirMIDI 1-1 '
client 74: 'Virtual Raw MIDI 1-2' [type=kernel]
0 'VirMIDI 1-2 '
client 75: 'Virtual Raw MIDI 1-3' [type=kernel]
0 'VirMIDI 1-3 '
client 88: 'MidiSport 2x2 - Rawmidi 3' [type=kernel]
0 'MidiSport 2x2 MIDI 1'
1 'MidiSport 2x2 MIDI 2'
How can I find out what midiindev I have to use?
Thank you a lot.
Write table with 256 values coming from a number b
I'm guessing your patch receives the 256 values in a list?
You can extract the Nth element from a list with a message box like [ $N (
But for a list length 256 this could get tedious to patch. What I suggest is making a Java program to make the patch.
Make a patch to extract the right parts from the list for a short list, say length 4, perhaps with a [ t l l l l] connected up to [ $N M (, where M=N-1, each connected to [ unpack f f ( ==> [ tabwrite ] . If you create the message boxes last, it will be easier to write the program.
Then write a Java program to generate the patch you want. It's best if the patch generated is a complete abstraction, so you don't have to edit the output patch each time you edit the Java program (say if you want different length lists).
Here is an example of a Java program that I wrote to generate a patch with 256 number boxes in a 4x64 grid. It doesn't follow my guidelines for being a complete abstraction - I edited the patch afterwards to add more stuff, which will cause me problems next time I want a different sized grid....
----snip-----
public class NumberGrid4x64 {
public static void main(String args[]) {
System.out.println("#N canvas 403 0 525 1216 10;");
int count = 0;
System.out.println("#X obj 2 18 cnv 15 110 1136 empty \\$0-canvas-r \\$1 4 12 0 10 -225280 -90133 0;"); count++;
for(int y = 0; y < 64; y++) {
for(int x = 0; x < 4; x++) {
System.out.println("#X floatatom "+(7+26*x)+" "+(42+16*y+4*((int)(y/4))+4*((int)(y/16)))+" 3 0 0 0 - #0-"+y+"-"+x+"-r #0-"+y+"-"+x+"-s;"); count++;
}
}
int count0 = count;
for(int y = 0; y < 64; y++) {
for(int x = 0; x < 4; x++) {
System.out.println("#X obj "+(120+200*x)+" "+(42+16*y+4*((int)(y/4))+4*((int)(y/16)))+" r \\$0-"+y+"-"+x+"-s;"); count++;
System.out.println("#X msg "+(220+200*x)+" "+(42+16*y+4*((int)(y/4))+4*((int)(y/16)))+" "+y+" "+x+" \\$1;"); count++;
}
}
int count1 = count;
System.out.println("#X obj "+(500)+" "+(18)+" t a;");
for(int c = count0; c < count1; c = c + 2) {
System.out.println("#X connect "+(c)+" 0 "+(c+1)+" 0;");
System.out.println("#X connect "+(c+1)+" 0 "+count1+" 0;");
}
}
}
----snip----
Client/server pd/java
I used the netserver and netclient from pd to create a cliente server that reads data from java into pd but I am not able to see inside pd objects and numbers boxes the values that java produces. I think the problem isn´t with java but with pd.
I use maxlib in java to get the values and send to pd with out.println(R_[]) but i can´t see them in pd where I need to work with.
Anybody can help me?
Thanx_