We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › how to map sound samples to screen grid
Page Index Toggle Pages: 1
how to map sound samples to screen grid? (Read 884 times)
how to map sound samples to screen grid?
Jul 26th, 2007, 11:39am
 
hello, everyone. Did anyone know how to map a list of sound
samples to a screen grid, so that i drag my mouse in different
screen position to play different sound sample?
I am having trouble to do this. Can help me out with this?
plz help.......
Re: how to map sound samples to screen grid?
Reply #1 - Jul 26th, 2007, 1:29pm
 
oh your grid declaration, you can add a sample id.
then by checking if your mouse position intersects a certain cell of the grid, it will play that sample associated to it..
should be too hard
Re: how to map sound samples to screen grid?
Reply #2 - Jul 26th, 2007, 2:00pm
 
Cheesy,thanks for the reply, that's what i mean.My english is not too bad...

Ok, i have some question on this. I use array to store the grid top left corner position, then i am trying to detect if the mouse has enter the grid. Am i going to use some loop functions( such as for...)? Would that be slow? Or if there are some other types of method or algorithm that i can use?

I am new  to programming, so...Can someone give me some code sample on this? if there are any..

Wink

Re: how to map sound samples to screen grid?
Reply #3 - Jul 26th, 2007, 2:52pm
 
If your grid is regular (i.e. every cell is the same size, and there's no gaps between cells) then you can very easily get the cell number with the following code (I think):

Code:

int cx=mouseX/cellWidth;
int cy=mouseY/cellHeight;

//the mouse in in the cell 'cx' across, and 'cy' down.

Re: how to map sound samples to screen grid?
Reply #4 - Jul 27th, 2007, 2:57am
 
Thanks John, I think it would work. Let me test it . Smiley
Page Index Toggle Pages: 1