Sound problems of Patches that moved from Windows 10 to Raspbian
Hello,
I've been making guitar effects with Puredata and Raspberry Pi.
Previously I did not care much about this problem, but at the last moment I got a terrible problem so I would like to consult with you.
I created Puredata Patches on Windows 10, copy Patches to Raspbian and use it.
In most cases there is no problem,
but depending on the Patches the sound reproducibility will be different.
Please help if there is a solution,thank you.
Windows_And_Raspbian.mp4
test.pd
*I uploaded same files in Google Drive and Dropbox.
1)There is a problem with the reproducibility of the sound, especially the problem is remarkable with the decay sound.
2)The problem is reproduced even if Windows 10 and Raspbian use the same USB Audio interface(Behringer UCG102)
3)Even if I use a different USB Audio interface (Zoom U - 22) in Raspbian, the problem is reproduced.
Font issue with new linux distros
@NoDSP It all works fine on Windows. OSX I have not heard of problems since Pd addressed them in 2011. Ubuntu, some problems after 16.04 (and sometimes before... but X-window). Generally a lot of Linux font problems on Google.
Sorry I am not helping with your particular problem.
You could try a.... sudo apt-get install --reinstall x-ttcidfont-conf ttf-dejavu....... if not done so already.
I am having trouble understanding why it should be a tcl issue when it works fine on other Linux distros.
Tk 8.4 was a problem..... but it's very old now......
But Pd will need a re-write (again) just for newer Linux. I don't know what other problems that will throw up for system compatibility. There was a long debate about it last time.
David.
MobMuPlat NUMPAD "template" (as .json + .pd abstraction) for direct and precise entry of #'s into MMP
Stemming from a different project, I've made a MobMuPlat (MMP) NUMPAD "template" so that numbers may be entered directy (and more Precisely) into MMP instead of selected from siders, knobs, or other controls (which apparently pd can do by just clicking a number field, typing in the number, and pressing ENTER (Thanks, again, @LiamG)
FEATURES:
Integers and Decimals from 1e-8 to 999999;
m+,m-,rcl: for storing (m+), removing stored number (m-) and recalling numbers (rcl)
cl:clear (but no backspace)
HOW-TO:
To test: in the MMP editor open the "mmp_numpad_template.mmp" file and experiment. (note: it will not start entering decimals until after you click "." and Then the next number). It is associated to the "abs_mmp_numpad_test.pd" which has the template embedded as an abstraction in it. It also has a slider on the second page, to test routing the ENTERed number to different "locations".
To implement:
First embed "abs_mmp_numpad_template.pd" as an abstraction in your MMP's .pd file. It has one outlet: the current value after the NUMPAD's ENTer is clicked and will receive all control signals coming from the NUMPAD.
Next, with a text-editor, open the "numpad-codeblock.jsn" file (or copy it from the code block below);
VERY IMPORTANT!!!: make a backup copy of your own mmp file before doing this.
In the text-editor, open "as-text" your .mmp file (or to experiment, the "pasteJSNtest.mmp" file which I have provided);
Past the numpad_template.jsn codeblock (from the file or the codeblock below), in between the mmp 'gui' brackets, as shown here:
{"backgroundColor":[0.5019608,0.5019608,0.5019608,1.0],"pageCount":1,"port":54321,"isPageScrollShortEnd":false,"startPageIndex":0,"canvasType":"widePhone","gui":[],"isOrientationLandscape":false,"version":1.64}
Once you have pasted it in, save your file, and open it in the MMP Editor.
The control and associated labels will be on the first page. You can move them, resize, etc. as you wish. And no matter where you put it (given its precise field names the entered value will get sent to the "abs_mmp_numpad_template" abstraction.
Sounds like a lot of work. But once you get the hang of it. I think it's well worth the effort: you will be able to have exact control over Any mmp value.
numpad-codeblock.jsn
{"mode":1,"highlightColor":[1.0,0.0,0.0,1.0],"borderThickness":3,"address":"/numgrid/0","color":[1.0,1.0,1.0,1.0],"dim":[4,4],"class":"MMPGrid","cellPadding":2,"frame":[10.0,115.0,300.0,360.0]},{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/myLabel","textSize":36,"color":[1.0,1.0,1.0,1.0],"androidFont":"Roboto-Regular","textFontFamily":"Default","text":"cl","textFont":"","class":"MMPLabel","frame":[175.0,405.0,50.0,45.0]},{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/myLabel","textSize":36,"color":[1.0,1.0,1.0,1.0],"androidFont":"Roboto-Regular","textFontFamily":"Default","text":".","textFont":"","class":"MMPLabel","frame":[35.0,400.0,40.0,50.0]},{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/myLabel","textSize":36,"color":[1.0,1.0,1.0,1.0],"androidFont":"Roboto-Regular","textFontFamily":"Default","text":"ent","textFont":"","class":"MMPLabel","frame":[235.0,405.0,75.0,45.0]},{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/myLabel","textSize":36,"color":[1.0,1.0,1.0,1.0],"androidFont":"Roboto-Regular","textFontFamily":"Default","text":"m-","textFont":"","class":"MMPLabel","frame":[245.0,225.0,60.0,45.0]},{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/myLabel","textSize":36,"color":[1.0,1.0,1.0,1.0],"androidFont":"Roboto-Regular","textFontFamily":"Default","text":"m+","textFont":"","class":"MMPLabel","frame":[235.0,315.0,75.0,50.0]},{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/myLabel","textSize":36,"color":[1.0,1.0,1.0,1.0],"androidFont":"Roboto-Regular","textFontFamily":"Default","text":"1","textFont":"","class":"MMPLabel","frame":[30.0,315.0,40.0,50.0]},{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/myLabel","textSize":36,"color":[1.0,1.0,1.0,1.0],"androidFont":"Roboto-Regular","textFontFamily":"Default","text":"2","textFont":"","class":"MMPLabel","frame":[105.0,315.0,40.0,50.0]},{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/myLabel","textSize":36,"color":[1.0,1.0,1.0,1.0],"androidFont":"Roboto-Regular","textFontFamily":"Default","text":"3","textFont":"","class":"MMPLabel","frame":[180.0,315.0,40.0,50.0]},{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/myLabel","textSize":36,"color":[1.0,1.0,1.0,1.0],"androidFont":"Roboto-Regular","textFontFamily":"Default","text":"4","textFont":"","class":"MMPLabel","frame":[30.0,230.0,40.0,50.0]},{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/myLabel","textSize":36,"color":[1.0,1.0,1.0,1.0],"androidFont":"Roboto-Regular","textFontFamily":"Default","text":"5","textFont":"","class":"MMPLabel","frame":[110.0,230.0,40.0,50.0]},{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/myLabel","textSize":36,"color":[1.0,1.0,1.0,1.0],"androidFont":"Roboto-Regular","textFontFamily":"Default","text":"6","textFont":"","class":"MMPLabel","frame":[185.0,230.0,40.0,45.0]},{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/myLabel","textSize":36,"color":[1.0,1.0,1.0,1.0],"androidFont":"Roboto-Regular","textFontFamily":"Default","text":"7","textFont":"","class":"MMPLabel","frame":[30.0,145.0,40.0,40.0]},{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/myLabel","textSize":36,"color":[1.0,1.0,1.0,1.0],"androidFont":"Roboto-Regular","textFontFamily":"Default","text":"9","textFont":"","class":"MMPLabel","frame":[185.0,140.0,40.0,50.0]},{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/myPanel","color":[0.6,0.6,0.6,1.0],"passTouches":false,"class":"MMPPanel","frame":[10.0,55.0,300.0,60.0]},{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/numlabel/0","textSize":42,"color":[1.0,1.0,1.0,1.0],"androidFont":"Roboto-Regular","textFontFamily":"Default","text":":256 ","textFont":"","class":"MMPLabel","frame":[15.0,60.0,290.0,55.0]},{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/myLabel","textSize":36,"color":[1.0,1.0,1.0,1.0],"androidFont":"Roboto-Regular","textFontFamily":"Default","text":"0","textFont":"","class":"MMPLabel","frame":[105.0,405.0,40.0,50.0]},{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/myLabel","textSize":36,"color":[1.0,1.0,1.0,1.0],"androidFont":"Roboto-Regular","textFontFamily":"Default","text":"8","textFont":"","class":"MMPLabel","frame":[105.0,140.0,40.0,50.0]},{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/myLabel","textSize":36,"color":[1.0,1.0,1.0,1.0],"androidFont":"Roboto-Regular","textFontFamily":"Default","text":"rc","textFont":"","class":"MMPLabel","frame":[250.0,135.0,50.0,50.0]}
Hope this may be of use to you.
Enjoy. And as a side comment: MMP is by far the fastest development environment I have ever worked in and is excellent as a ProtoTyper (tho admittedly my experience is limited). It works GREAT as an OSC-Controller, too. Daniel has done us all a great service by building it. Additionally kudos, to the PdDroidParty and libPD developers upon whose backbone it is built.
Many Happy Returns,
Scott
MMPonBoardEditorTemplate.mmp for creation of MobMuPlat files directly on the handheld (android only)
MMPonBoardEditorTemplate.mmp for creation of MobMuPlat files directly on the handheld (android only)
MMPonBoardEditorTemplate
by svanya
INFO: make copies of this template to use as the starting point for your created .mmp files.
This template is designed to expedite the creation of simple(!) MobMuPlat files on-the-go with only the use of the handheld (i.e. does not require the Java editor).
There are three sections to this document:
the templates (in this commented section)
the mmp header just below this section
the "ENTRIES SECTION"
and
the mmp footer (which closes the .json file).
To use the template:
Open this file in a handheld text-editor (you may need to rename it, ex. adding ".txt" (no quotes) to the end of its file name to associate it to the text-editor and NOT MobMuPlat).
Copy one of the sections from this Templates Section (not including its label and the label colon and paste it into the Entries Section below and for each template you have added more than 1, add a comma after each template except the last one.
The arrangment on the screen can then be edited (in that same text editor) by amending the "frame" section of each Entry according to the following format:
"frame":[left,top,width,height]
(on the JAVA editor the screen is scaled 320px wide by 480px high)
and
Re-open the .mmp file inside MobMuPlat (renaming it back to .mmp as necessary).
Enjoy! And Good Luck! Just post any comments or help you may need here and I will try and get to them as soon as I am able.
Ciao for Now. Peace,
svanya
for those interested here is the code:
/*
MMPonBoardEditorTemplate.mmp for creation of MobMuPlat files directly on the handheld (android only)
MMPonBoardEditorTemplate
by svanya
INFO: make copies of this template to use as the starting point for your created .mmp files.
This template is designed to expedite the creation of simple(!) MobMuPlat files on-the-go with only the use of the handheld (i.e. does not require the Java editor).
There are three sections to this document:
the templates (in this commented section)
the mmp header just below this section
the "ENTRIES SECTION"
and
the mmp footer (which closes the .json file).
To use the template:
Open this file in a handheld text-editor (you may need to rename it, ex. adding ".txt" (no quotes) to the end of its file name to associate it to the text-editor and NOT MobMuPlat).
Copy one of the sections from this Templates Section (not including its label and the label colon and paste it into the Entries Section below and for each template you have added more than 1, add a comma after each template except the last one.
The arrangment on the screen can then be edited (in that same text editor) by amending the "frame" section of each Entry according to the following format:
"frame":[left,top,width,height]
(on the JAVA editor the screen is scaled 320px wide by 480px high)
and
Re-open the .mmp file inside MobMuPlat (renaming it back to .mmp as necessary).
TEMPLATES:
MMPLabel:
{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/label/0","textSize":16,"color":[1.0,1.0,1.0,1.0],"androidFont":"Roboto-Bold","textFontFamily":"Default","text":"label","textFont":"","class":"MMPLabel","frame":[150.0,10.0,100.0,40.0]}
MMPButton:
{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/button/0","color":[1.0,1.0,1.0,1.0],"class":"MMPButton","frame":[10.0,70.0,100.0,40.0]}
MMPToggle:
{"highlightColor":[1.0,0.0,0.0,1.0],"borderThickness":4,"address":"/toggle/0","color":[1.0,1.0,1.0,1.0],"class":"MMPToggle","frame":[10.0,130.0,100.0,40.0]}
vSlider:
{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/vSlider/0","color":[1.0,1.0,1.0,1.0],"range":2,"class":"MMPSlider","isHorizontal":false,"frame":[10.0,190.0,100.0,40.0]}
hSlider:
{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/hSlider/0","color":[1.0,1.0,1.0,1.0],"range":2,"class":"MMPSlider","isHorizontal":true,"frame":[10.0,250.0,100.0,40.0]}
MMPKnob:
{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/knob/0","color":[1.0,1.0,1.0,1.0],"indicatorColor":[1.0,1.0,1.0,1.0],"range":2,"class":"MMPKnob","frame":[10.0,300.0,100.0,100.0]}
MMPXYSlider:
{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/xyslider/0","color":[1.0,1.0,1.0,1.0],"class":"MMPXYSlider","frame":[10.0,420.0,100.0,40.0]}
MMPGrid:
{"mode":0,"highlightColor":[1.0,0.0,0.0,1.0],"borderThickness":3,"address":"/grid/0","color":[1.0,1.0,1.0,1.0],"dim":[4,3],"class":"MMPGrid","cellPadding":2,"frame":[150.0,70.0,100.0,40.0]}
MMPMultiSlider:
{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/multislider/0","color":[1.0,1.0,1.0,1.0],"range":8,"outputMode":0,"class":"MMPMultiSlider","frame":[150.0,130.0,100.0,40.0]}
MMPLCD:
{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/lcd/0","color":[1.0,1.0,1.0,1.0],"class":"MMPLCD","frame":[150.0,190.0,100.0,40.0]}
MMPMultiTouch:
{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/multitouch/0","color":[1.0,1.0,1.0,1.0],"class":"MMPMultiTouch","frame":[150.0,250.0,100.0,40.0]}
MMPTable:
{"mode":0,"highlightColor":[1.0,0.0,0.0,1.0],"address":"/table/0","color":[1.0,1.0,1.0,1.0],"selectionColor":[1.0,1.0,1.0,0.5019608],"displayRangeLo":-1.0,"displayRangeHi":1.0,"class":"MMPTable","displayMode":0,"frame":[150.0,310.0,100.0,40.0]}
MMPPanel:
{"highlightColor":[1.0,0.0,0.0,1.0],"address":"/panel/0","color":[1.0,1.0,1.0,1.0],"passTouches":false,"class":"MMPPanel","frame":[150.0,370.0,100.0,40.0]}
THE ACTUAL MMP FILE FOLLOWS THIS
*/
{"pdFile":"osc_controller_mmp.pd","backgroundColor":[0.0,0.0,0.0,1.0],"pageCount":1,"port":54321,"isPageScrollShortEnd":false,"startPageIndex":0,"canvasType":"widePhone","gui":[
/*
ENTRIES SECTION: entries go below here and above the comment below
*/
/*
END: ENTRIES SECTION
The mmp footer is below.
*/
],"isOrientationLandscape":false,"version":1.64}
GUI Plugins: Where are redraw colors stored?
I actually managed to make a plugin that colors every window in 8.4, not sure about previous versions. I just uncommented the create tcl_entry command at the bottom of the pdwindow tcl file (which enables the command prompt), used it to inspect all the windows and options, then kind of hacked away with a recursive proc. It worked for me on .46 - mac.
here it is ketea-theme-plugin.tcl You can see if that works?
It was even coloring the embedded_button_bar-plugin but @danomatika made a tk 8.6 version however; the way the frame was rendered became ugly so I thought I should refactor things into grid instead of pack. But thats different problem.
I'm pretty sure that my answer lies within syscalls in the c code, but I have zero knowledge of either the control flow on the c-side or syscalls in general.
Like look at this :
tcl:
#change the text in an existing text box
proc pdtk_text_set {tkcanvas tag text} {
$tkcanvas itemconfig $tag -text $text
}
inside a giant c function called rtext_senditup
else if (action == SEND_UPDATE)
{
sys_vgui("pdtk_text_set .x%lx.c %s {%.*s}\n",
canvas, x->x_tag, outchars_b, tempbuf);
if (pixwide != x->x_drawnwidth || pixhigh != x->x_drawnheight)
text_drawborder(x->x_text, x->x_glist, x->x_tag,
pixwide, pixhigh, 0);
if (x->x_active)
{
if (selend_b > selstart_b)
{
sys_vgui(".x%lx.c select from %s %d\n", canvas,
x->x_tag, u8_charnum(x->x_buf, selstart_b));
sys_vgui(".x%lx.c select to %s %d\n", canvas,
x->x_tag, u8_charnum(x->x_buf, selend_b) - 1);
sys_vgui(".x%lx.c focus \"\"\n", canvas);
}
else
{
sys_vgui(".x%lx.c select clear\n", canvas);
sys_vgui(".x%lx.c icursor %s %d\n", canvas, x->x_tag,
u8_charnum(x->x_buf, selstart_b));
sys_vgui(".x%lx.c focus %s\n", canvas, x->x_tag);
}
}
}
...I might be able to hijack these arguments, but I'm not sure how yet.
udpsend and receive
GNU nano 2.2.6 File: /etc/network/interfaces
interfaces(5) file used by ifup(8) and ifdown(8)
Please note that this file is written to be used with dhcpcd
For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet manual
#allow-hotplug wlan0
#iface wlan0 inet manual
#wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan0
iface wlan0 inet static
address 10.1.1.101
netmask 255.255.255.0
network 10.1.1.0
broadcast 10.1.1.255
gateway 10.1.1.1
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Pure Data / Raspberry Pi / Realtime Audio / Permissions
THE GOAL:
I want my Raspberry Pi 2 to automatically start up the Jack server with realtime scheduling, and subsequently start Pure Data with realtime scheduling, load a patch &c. without any user intervention from a login shell.
As a performance artist working primarily with psychodrama (the technology is definitely NOT the important part here), fiddling around at a terminal right before or during a performance is kind of... psychically inconvenient. I need a box that I can plug in, give the audio output to the sound guy, and be ready to go.
PREREQUISITES:
I use Raspbian with a Linux kernel compiled with realtime goodness. I have hand-compiled Jack2 and Pure Data with realtime support in order to take advantage of this. Running a process with realtime priority requires the proper PAM directives set in /etc/security/limits.conf and related places, but that is beyond the scope of this little write-up.
Also somewhat relevant: I use a M-Audio MobilePre USB soundcard (sounds pretty awful by today's standards, but it's an extremely USEFUL box and sounds good enough for the work I do). For full-duplex sound, this requires the RasPi's USB to be set to single speed. In this configuration, I can get just under 2.9ms latency with good CPU overhead for Pure Data to run a few of my 64-voice wavetable and delay line granulators. Yeah!
THE PROBLEM:
Purely by happenstance, I had given the jackd command in my startup script the option “-s” which allows the server to ignore overruns and so on. So things seemed to be working as expected, but I noticed a lot more glitches than when I manually started up Jack and Pd from the terminal without the “-s” option. Upon removing it from my startup script, everything failed! WAH.
So I started piping STDERR and STDOUT to text files so I could read what either Jack or Pd were complaining about. As it turns out, Jack was unable to start with realtime priority due to a permissions problem. (I assume this is one of the things the “-s” options allows jackd to ignore, and thus start up with non-realtime priority. Problem is that Pure Data can’t connect to a non-realtime Jack server when its “-rt” option specified.)
Now, I had already been through the whole rigamarole of setting proper memory and priority limits for the “audio” group, to which the user “pi” belongs. So I thought, okay, I have to execute these commands as “pi”, and while simulating a login shell because the security limits in question are only set during login.
So I did this:
su -l pi -c "/usr/local/bin/jackd -R -dalsa -dhw:1,0 -p128 -n3 -r44100 -S >> /home/pi/jackd.log 2>&1 &"
This says “login as user ‘pi’ and then run the jackd command with these options, piping the outputs to this log file and run it in the background”. Well, I still got all the same errors about not being able to set realtime priority. WHYYYYYYYYY?
THE SOLUTION:
I hunted and hunted and hunted on a Very Popular Search Engine til I decided to try searching “security limits not loaded with su -l” and found this.
(Makes me think of that Talking Heads lyric, “Isn’t it weird / Looks too obscure to me”.)
So by uncommenting the line # session required pam_limits.so
in /etc/pam.d/su
everything started working as expected.
CONCLUSION:
I now know a LOT MORE about PAM and how important it is to keep in mind when and in what order scripts and other little subsystems are executed; but also that sometimes the problem is EXTREMELY OBSCURE and is to be found in some seemingly far-flung config file.
I hope this helps anybody out there working with Pure Data and the RasPi. The second generation board really packs quite a punch and can run several hundred audio grains (run by vline~ and enveloped by vline~ and cos~) simultaneously without a problem. And I'm pretty sure this is just using ONE of the 4 cores!
I'm by no means an expert Linux sysadmin, so if you have any other suggestions or corrections, please let me know! I wouldn't have been able to get this far without all the generous and helpful writeups everybody else has contributed, both within the RasPi and Pure Data communities. If you have any questions about anything I glossed over here, I'll do my best to answer them.
Set up the path for abstractions
hey,
I don't know but I wonder if maybe there isn't a more general problem going on right now (though it seems simple and wierd so I dont get it)
I am also having trouble loading abstractions even though I have done it quite a lot before, in particular (I posted this problem a few days ago but am posting in response to your problem in hopes that it might be a more global problem - though my abstractions, other than the ones mentioned below, load so I dont understand)
specifically, was the problem with the path not being recognised?
anyway -
Hello everyone,
This is a strange problem because I have loaded libraries and things with the 'Paths' dialog under the file menu before and had no problems.
I am trying to get Chris McCormick's s-abstractions to load. The folder is in the same folder as my other libraries and it is listed in both the "paths" and "startup" areas. It wasn't before but I added it.
I am running windows 7 64 bit. Another oddity that I noticed is that in my Program Files (x86) which is where the 64 bit programs live, I have pd installed and the folder is simply called pd. However in the Program Files folder (missing the x86, where the non-64 bit programs live) I have a folder called "Pd-0.42.5-extended"
I wonder if that couldn't be the problem. The s-abstractions folder is included in both though...
Hopefully somebody has some idea about this...
((anyway sorry to post twice but I hoped maybe there was some common problem there))
Arduino, ultrasonics and Pd: HELP needed for degree project!
Dear Pd'ers… I'm fairly new to Pd and have been using it during my 'Audio Production' degree at SAE college in London. I'm here to ask for help on my final degree project, which aims to control objects within Pd by way of proximity sensors connected to Arduino.
I have had moderate success, first using a Sharp GPD12 IR sensor connected to an analog port on an Arduino Diecimila, then a Devantech SRF02 connected via I2C to Arduino. I have managed to get Pure Data reading the sensor values using the Pure Data example included in SimpleMessageSystem (http://www.arduino.cc/playground/uploads/Code/SimpleMessageSystem.zip)... and only altering the number of the comport the Arduino appears on.
On the Arduino end, I have added the SimpleMessageSystem library, and am using the following sketch to run one or both of the sensors depending on whether or not I omit the SRF02 or GPD12 parts of the code.
// top //
#include <Wire.h>
#include <Servo.h>
#include <SimpleMessageSystem.h>
int sensorPin = 0;
int sensorValue = 0;
Servo servo1;
#define sensorAddress 0x70
#define readInches 0x50
#define readCentimeters 0x51
#define readMicroseconds 0x52
#define resultRegister 0x02
void setup()
{
Wire.begin();
Serial.begin(9600);
}
void sendCommand (int address, int command) {
Wire.beginTransmission(address);
Wire.send(0x00);
Wire.send(command);
Wire.endTransmission();
}
void setRegister(int address, int thisRegister) {
Wire.beginTransmission(address);
Wire.send(thisRegister);
Wire.endTransmission();
}
int readData(int address, int numBytes) {
int result = 0;
Wire.requestFrom(address, numBytes);
while (Wire.available() < 2 );{
}
result = Wire.receive() * 256;
result = result + Wire.receive();
return result;
}
void loop()
{
// SRF02 READING //
sendCommand(sensorAddress, readInches);
delay(70);
setRegister(sensorAddress, resultRegister);
int sensorReading = readData(sensorAddress, 2);
Serial.println(sensorReading);
delay (200);
// GPD12 READING //
sensorValue = analogRead(sensorPin);
int range = (6787 / sensorValue);
Serial.println(range);
delay(200);
}
// bottom //
Pure data is picking up the sensor's output as a decimal number, through the serial port, correctly, and showing this as a number in the SPECIAL CHARACTER section of the Pd patch, which I can then use to control various Pd parameters, like a slider for example.
If printing both sensor readings to the serial, the Pd patch will pick up the two sensor values alternately, but there seems no way of differentiating the two sensors within Pd, as they both come through the serial. I have tried prepending the serial print at the Arduino stage with a tag such as "IR" or "UL" for each sensor, but this simply ends up in nothing coming through in Pd.
Using one sensor gives the ability to control parameters with a fairly narrow detection range, but for the final version I would like to incorporate 4 or 5 sensors in order that I can cover nearly a full 360 degree range.
After a bit of research I have gone and bought 4 x Maxsonar EZ0's. They've got a wider range than the Devantech sensors, and can operate via I2C, serial or PWM. A number of people online seem to mention the improved stability when operating via PWM, so I thought this could be kinda useful.
I am going to London Hackspace tomorrow to get help with wiring up the sensors to my Arduino Diecimila, but for now, my main problem seems to be how to achieve greater communication between Pure Data and the sensors. It's all very good and well being able to take the decimal readout from an analog input to give one set of values in Pd, but I would like to know how to either to read (and trigger) each sensor discretely via PWM, or to somehow differentiate between each sensor's analog output, so that I can have the different sensors controlling different objects within Pd.
As well as SimpleMessageSystem, I looked at using the Pduino object. But to be honest, it is either not working properly (I have noticed reported issues with bugginess), or I am being stupid, as it has totally boggled my brain. In theory though, it seems like it should be able to do what I want, ie. send and receive commands between Arduino and Pd.
****************************************
So…. my questions for anyone out there with a knowledge of using Arduino + multiple sensors (preferably Maxsonar EZ's) with Pd are:
What is most appropriate for my project?
- Simple Message System or Pduino?
- analog or PWM?
And how do I get proper communication between the two platforms so I can discern discrete values from each sensor?
I'd really like to get a discussion going with this as (a) it would really help me in my degree (which ends in about 4 weeks!!!) and (b) I really want to share what I am doing, especially as the discussions on Arduino/Pd communication on the various forums seem a little patchy (at least for noobs like me). I also hope to continue my research in the future, sharing any findings I make with the community…
****************************************
PS. In the sharing spirit, please check out the Radio Tuner patch I've just posted over on the patch section of this forum - it's my first successful attempt at Pd... I hope you enjoy
VisualTracker - request for participants
Here is some more info:
This is development info of VisualTracker for pd (pre alpha 100404)
What is it:
VisualTracker is sample sequencer – it triggers loaded samples in times defined in time line in editor window. Samples can be played in their default speed / length or can be fitted in tempo. In “fit mode” you can define number of bars to fit in and also multiplication of file. All changes have visual interpretation in sample canvases.
VisualTracker for pd (pre alpha 100404) was developed in Pd version 0.41.4-extended, on Windows XP
How to make it work:
- Open VisualTracker_(pre_alpha_100404).pd in pd.
- Editor and Samples window are automatically opened.
- Preset currentstate.vtp is automatically loaded – this preset is saved before closing the patch.
- After first run there are 3 empty sample boxes in samples window and 3 corresponding sample canvases in editor window.
- Load any wav (44100 Hz) by pressing „load“ in selected sample box. No space characters in path or filename are allowed. Loading of these files is aborted and error message appears for several seconds. Name of the successfully loaded sample including full path appears in sample box and also sample canvas in editor window. Size of sample canvas is changed according to the sample length. Try to change global BPM – size of sample canvas is recalculated.
- Check „fit“ to fit sample in current BPM. Set length of sample in bars and multiplication.
- Add another sample by creating object [sample] or just copy existing sample box in samples window.
- Switch to editor window, press CTRL+E to switch to pd edit mode and drag and drop sample canvases to desired position on time line. Sample canvases are automatically snapping to bar columns and rows.
- Switch back to normal mode by CTRL+E
- Press PLAY to replay your sample composition. Samples are played only if corresponding sample canvas is placed in track 1-6. If sample canvas is above the tracks sound is muted.
- Press „save“ in main VisualTracker window to save current preset to a text file. Any name and extension with no spaces is allowed.
- Before closing VisualTracker press „save state & close“. It saves current state to preset named currentstate.vtp and delete all sample boxes from samples window and all sample canvases from editor window. Now you can turn off and eventually save VisualTracker patch. This is important to avoid double appearance of sample canvases because information about samples and composition is stored independently from pd patch and should not be saved inside patch. If there are still some „orphaned“ sample canvases hanging delete them manually.
Components:
- Sample window: place for unlimited amount of [sample] abstractions. Once abstraction is created (by copying or creating the object) corresponding sample canvas is created in editor window. [sample] abstraction is sending data to sample canvas (name, color, size, snapping) and receiving back position. Triggering of sample playback is based on position of sample canvas.
- Editor window: place for sample canvases composition on the top of timeline grid. Sample canvases can be moved by mouse in pd edit mode (CTRL+E). Timeline grid will be extended and improved in next versions.
- Preset save/load: saves and loads presets to/from a text file using [coll] object. Preset contains global values (number of samples in composition, bpm) and local values for each sample box (filename, position, track, multiplication, number of bars, fit switch, color and two unused values).
- Sequencer: located in program subpatch. Very simple - functionality will be extended and improved in next versions
- Other: located in program subpatch. Contains some other patches as colortable, BPM manager, output etc.