We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm currently trying to create a visual diagram of solar winds within processing, but I'm struggling on trying to structure it and I need help.
Using http://services.swpc.noaa.gov/text/ace-swepam.txt I need to collect proton density, bulk speed and ion temperature and create a visual diagram which I will get into once I've collected all 120 points of data (1 per minute over the course of 2 hours)
I've worked with txt files before because they're easier to determine and separate different values, but I would still struggle with removing certain values from a row of multiple values.
This was my original idea on how to do it, but doing it this way would require copying and pasting this 120 times and adjusting it along the way.
I want to do what I've done, but using i+ 120 times to get everything stored in a single array but I have no idea how.
Answers
The best way would be to create a class
Record
which holds all the data for a single line in an accessible format.This code reads the data from the file and creates an array of Records, one element for each line of data.
If you run the following sketch it should become apparent how it works but if you need anything explaining just ask.
So how exactly would I be able to use the speed, density and temperature to create a visual? For example to determine the shape and size of a triangle? I mean, in terms of taking the data out of the array you've made rather than "how do I make a triangle".
You last comment makes no sense.
What do you want to visualise?
Where does a triangle come into the visualisation?
Well, considering there are three different values I want to present for each minute, a triangle was the first thing that came to mind. Either that or something else that I can do for each minute of the data.
Anyway, point being; How do I take data out of the array you've made?
See line 10 for that
Call showSomeData from draw()
Since this is data over time think of it as a graph :
X-axis is time (120 steps)
And on y-axis use three colors (one color for density, one for speed etc.), make ellipses for each value (connect with lines if you like, but that's controversial maybe)
you need to do some scaling to get all data fitting into the screen ;-)
So, how would I go about to show off the value of each data set? As the way it's presented is impossible to read and compare the data in terms of what the values actually are as proton density is usually between the values of 0-2, but the bulk speeds are 300-400.
Maybe I should use three different graphs so it's easier to value each set of data as individual values? And in terms of actually making it seem more presentable, how would I go about to connect each form of data with a line so it's easier to tell that "this data is at the same time of this data".
Just use 3 times the command line() with x values always the same and y values of the data (to connect data recorded at the same time vertically)
But I'm not sure how to do that because of all the multipliers being added in order to make the graph more presentable in terms of comparing data.
I got it;
Jesus, thanks a LOT for the help.
how do I remove singular irregular data?
(see speed value on the far right for example of irregular data)
Also the 10th value seems to be non Existent
You can check with if if they are outside screen
is there anyway to create audio feedback based on the data collected?
Sure.
Look at the section libraries, either library sound or minim
minim?
Is it not on the library page? It is also a library.
Then google it
@CentricArts -- The minim sound library (available in PDE Contributions Manager), and recent minim discussions:
So how exactly would I be able to use the data I've collected and execute 3 different sounds that effect the pitch depending on the data in the table.
So if I hover over a value, it would play 3 different sounds. One for speed, density and temperature which are effected in pitch based on a multiplier which would be the data itself.
But how would I go about reading mouse data and array data to execute that is by using void mousepressed() would require me to out of the records[], how would I got about collecting and using the data?
This next post talks about how to get the data that is under the mouse pointer: https://forum.processing.org/two/discussion/23097/how-can-i-determine-which-spectrum-is-generated-from-which-file-on-mouseclick#latest
For data into audio, check: http://code.compartmental.net/minim/javadoc/ddf/minim/AudioOutput.html
You can populate the buffer and then play it. You can see more examples from previous posts: https://forum.processing.org/two/search?Search=audiooutput
Kf
I don't need to collect data under the mouse pointer, I already have the data stored in records[]. I've already made if statements to read if the mouse is in a certain area, depending on the area will depend the sound it plays back.
My question is, considering I've created the code based on a record[] based format, how exactly do I collect the data to take it out and put it in mousepressed? I've always used arrays to solve these problems but it's difficult considering the data I have is only usable in records[]
I was thinking of an array that stores whatever is in the r.speed[], r.density[] and r.temp[] so I can use it outside of the records, but I'm not really sure on how I would do that.
tldr; How do I use r.speed[] outside of showSomeData();
Explanation
normally you have e.g.
float [] listOfFloats;
it's an array of
float
. An expression likelistOfFloats[12]
gives you a number.here you now have
Record[] records;
which is an array ofRecord
:Other than float, each Record has a couple of items defined in the class Record: float density, speed, temperature etc.
(there is a tutorial on objects you might want to read:
https://www.processing.org/tutorials/objects/ )
To access one Record in the array use the dot
.
:So instead of having multiple parallel arrays speed[] and density[] etc., we have only on array and in each slot of it there is one speed, one density etc. Record.
r.speed[]
is wrong it's justr.speed
The
r
stems from the for-loopfor (Record r : records) {
(which in turn is a short version of the classical for-loop)
it says: copy each item of the array
records
intor
(being of type Record) one after the other, so it loops over each Record inrecords
.Classic form would be
So your answer is: you can say
records[12].speed
orrecords[i].speed
anywhere in your code. Not only inshowSomeData()
Chrisir ;-)
Oh fuck, that's easier than I thought. I understood how record[] worked but I didn't understand how to use it other than in the showSomeData(); as it directly refers to r.records when r. isn't a thing anywhere else. It's just an alternative to addressing something in a section of code that's designed to deal with this kinda stuff as a mainstream.
But yeah, records[i].speed was all I wanted to know. Thanks!
Great !
Is there any other way to do something like this 120 times more efficiently? (ignore the L value, I was trying to sort out a loop to check this for me but it didn't work)
You could just play the data from left to right automatically once the mouse is pressed
I am not sure what your goal is.
Do you want a program where you click on one column with the mouse and then the three data points of it are played one after the other?
Then you need to for loop over the columns and check if mouse position is inside.
Look deeper into minim - or sound library.
You can just tell it to play a tone with a frequency
it reads the data of the mouse and depending on the values of temp and density, for that column it will play different pitches in sound based on multipliers of the data its presenting in the table. The time between the two notes are then dependent on the speed of the wind.
The max speed of speed is around 800, so 800-records[sl].speed. [sl] is me trying to create a loop to detect the horizontal value in a database as the grid but that doesn't work because mousepressed() is event driven information and without information it can't do shit.
Which is the thing I'm struggling with to prevent me copying and pasting the same code 120 times.
Ok, i guess that's just some basic stuff you will learn easily
In mousePressed make a for loop similar to the one you have for the output in showSomeData
Here you use the same x value and say if(mouseX>x-3&&mouseX<x+3) {......
then just use the int i of the for loop to access the array records[i].speed and trigger the note / tone / sound with that pitch --- do the calculations on the fly in the if-clause (which is nested in the for loop)
I think I got it! I just have to change the pitch. How do I change the pitch of a imported .wav file?
I have no idea
As said I think you don't want a wave but rather a note / tone
I've tried to look up this stuff but it's really complicate as it centers around how to generate sound rather than how to use it based on other aspects like multipliers. I just need a way how to generate a sound and change it through pitch using minim. no idea how.
Maybe look at sound library (name is sound) or minim examples/ reference
I can look into it tonight
these codes are all not by me
here is another one:
Jesus Christ. I have no idea what half of this code is for and how to even use it in the slightest in my own.
Now, these are 2 sketches.
Try the first one- it's pretty straight forward
I've tried using the first one, but I can't even get an output using the values in my data
I'm probably missing something obvious but I'm not sure what it is.
I am not at home today maybe somebody can jump in
this has to be completed by tomorrow morning, so I doubt it.
However, I did come up with an alternate solution towards my problem but it isn't as well implemented as actually having pitch shifts as it's easier to tell the difference between different values.
But if nothing arises I thank everyone for giving me a hand with doing this
Which time zone?
Post your entire code as text
this isn't the final version of the code, but it is the code that I was trying to get pitch tones depending on different values of data when you click.
The 17th is when the hand in is at 3pm, GMT. But I'm leaving tomorrow afternoon at 12pm so I have to hand in before that time.
Did the pitch thing work?
No, that's why my backup is just three notes with delays based on speed*density and (temp/speed)/100
it works fine, but as I said previously, pitching would be easier to differentiate between values easier