How to reproduce the sound effect of a spin wheel created with speed or arc

I want to play a sound while the wheel is spinning. In accordance with the angle and coordinate the speed of rotation of the wheel.

I want to play the sound at the right time when Pin touches the linear touch of Arc.

Also, want an animation on the Pin when touched, like Shaking.

A sound is a reproduction, but the sound is continuously reproducing and is not looking for coordinates. According to the 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 the wheel of ITCenter 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

+5
source share
1 answer

So, if I understand correctly, you want to adjust the sound based on the speed of the wheel and play it whenever it hits one of your contacts.

Playing it back whenever it hits one of the contacts should be a mathematical question if it plays continuously, which would mean that your wheel spins quickly and the sound you play is longer than the duration between the two contacts, I guess.

You can play with the speed and pitch your sound. If you use MediaPlayer , you can change PlaybackParams to match this - go to setPitch and setSpeed .

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

+2
source

Source: https://habr.com/ru/post/1273071/


All Articles