Saturday, November 11, 2017

How to play sound effect of spin wheel co-originated with the speed or Arc line

Leave a Comment

I want to play sound on rotating the wheel According to angle and coordinate the speed of wheel rotating

I want to Sound Play on right time when the Pin touch on - line touch of Arc.

Also, Want to Animation on Pin when touch like Shaking.

Sound is Play but the Sound Continuously play and seeking not Coordinates According to Canvas wheel

 @Override protected void onDraw(Canvas canvas) {     super.onDraw(canvas);     drawWheelBackground(canvas);     initComponents();      float tempAngle = 0;     float sweepAngle = 360 / mWheelItems.size();     if (this.mWheelItems != null) {          Log.e("mWheelItems.size()", String.valueOf(mWheelItems.size()));         for (int i = 0; i < mWheelItems.size(); i++) {             archPaint.setColor(mWheelItems.get(i).color);             archPaint1.setColor(Color.WHITE);              canvas.drawArc(range, tempAngle, sweepAngle, true, archPaint2);             canvas.drawArc(range, tempAngle, sweepAngle, true, archPaint);              drawImage(canvas, tempAngle, mWheelItems.get(i).bitmap, mWheelItems.get(i).mvalue, sweepAngle);          }         if (!(this.resourcePlayer == null)) {              if (this.resourcePlayer.isPlaying()) {                 resourcePlayer.setVolume(100, 100);                 this.resourcePlayer.seekTo(0);              } else {                  this.resourcePlayer.start();              }         }      } } 

Rotation according to wheelItemCenter and 360 degrees

   final float wheelItemCenter = 180 - getAngleOfIndexTarget(target) + (360 / mWheelItems.size()) / 2;     animate().setInterpolator(new DecelerateInterpolator())             .setDuration(DEFAULT_ROTATION_TIME)             .rotation((360*5) + wheelItemCenter) 

enter image description here

1 Answers

Answers 1

So if I'm understanding correctly, you want to adjust the sound based on the wheel's speed and play it whenever it hits one of your pins.

Playing it whenever it hits one of the pins should be a math-question, if it plays continuously that would mean that your wheel is spinning fast and that the sound you're playing is longer than the duration between hitting two pins, I assume.

You can play around with the speed and pitch of your sound. If you're using a MediaPlayer you can change the PlaybackParams according to this - check out setPitch and setSpeed.

The faster your wheel is, the higher is the speed / pitch of your sound. The slower it gets, the more you also slow down the sound.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment