How to compare if background color is red?

Hi,
i want to make simple sequencer. I have 8 buttons and i can tap it to change its backgroundcolor to red or second tap to back it on color white. I made also connection that when background color is red the “ukryty_01_mute” button take “1” in its text.

What i want to do is to make my Player sound when button has background color red (and so ukryty_01_mute button takes “1”). When backgroundcolor is white (ukryty_01_mute button is “0”) there should be no sound.

App has to go from button 1 to 8 by one and check the background color.
I couldn’t make it correct. I also tried to made a list “colorRed” and i put there ealier 8 “backgroundcolor” buttons and tried to compare it if color is red but it doesn’t work.
Is there a way my app could go and check the actual background color or if “ukryty_mute” button is “0” or “1”?

You are nearly there.

Try using the button background colour block

component_set_get

Test this against the colour red

color_red

and do much the same for your other buttons

Thanks but maybe i wasn’t clear, it would work only if i use exactly as you show:
‘’’
if button.backgroundColor1 = red
do start.player1
‘’’

but i can’t do that beacuse i want app goes from button 1 to 8 (not play it all simultanously).
That’s the case - to check if ButtonColor1 is red (if is red then play sound), then go to ButtonCollor2 to check if is red (if is red then play sound), then go to …

You will probably need to use a clock timer to test the state (colour) of your buttons.

Will pressing another button change the button1 colour to white and stop the player (for button1) ?

Have a look at the xylophone tutorial, may give some ideas ?
http://www.appinventor.org/Xylophone2

Here’s a Morse Code sequencer, to demo
how to use lists to drive a sequence…

Clock Timer will not help unfortunately because it will check each time the backgroundColor of Button1, then 2,…,.
So if Button 1 color is red (plays sound) and Button 2 color is white (should be no sound) but Clock Timer will start checking from start and will see that Button1 is red so will tell Player to make volume audible.

This xylophone tutorial i read at start with this project but it shows how to play sounds automaticly when you press button. In my case you cilck start and app should go through all 8 buttons and check on each step if play sound or mute.

To answer your question
“Will pressing another button change the button1 colour to white and stop the player (for button1) ?”
I don’t exactly follow what you mean. If i.e. button3 is white it should be muted and then app should check if button4 is red or white.

Thanks but couldn’t find there a solution to my case

Can we take a step back and look at your workflow?

Do you want the sounds to play in sequence from 1 - 8 automatically and use the buttons to show (by colour) which sound is playing? (from what you have said it seems to be around the other way, which is more complicated - if the button is red play the sound, don’t play the other sounds.

Could you please explain your workflow in detail, then we can find a solution :slight_smile:

Ok :slight_smile:
Let’s say i want to make a loop of 8 steps. That’s why it is 8 buttons.
When i hit Play button and all buttons from 1 to 8 are red app should make a 8 sounds one after another.
And i.e. when only buttons nr 1, 3, 5, 7 are red you hear only 4 sounds (because step 2,4,6,8 should be muted or we can program it to be just lower at volume to illustrate better).

So app always play 8 sounds but one after another, just the volume is different because of the color of each step. :slight_smile:

OK, so pressing a button should not play a sound, it should just change the colour of the button to tell the sequencer whether it should be played or not, when the sequencer is started ?

Try this:

Blocks

AIA

sequencer.aia (89.4 KB)

Hey,
thanks for the input but that’s not exactly what i am trying to achive.

You created Button10 and 11 which are not necessary because i programed already that when click on any button from 1 to 8 it changes color.

Next you programmed Button9.click

  • i don’t know why adding items to the list?
  • set player source is unnecesery because i use only one sound (let say it is kick-drum sound).

So once again, i need:

  • 8 steps of one sound
  • steps are playing on two volumes (60 and 0) depending on the colour of the button.

So the sequence always go from button 1 to 8 and:

  • buttons that are red we hear it’s steps at volume = 60.
  • buttons that are white we hear it’s steps at volume = 0.
    Rick

I believe I answered your original question.

1 Like

Can you post an example of another app or anything that works the way you want your app to work?