• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
logic problem. adding sine wave pattern to dynamic float
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

logic problem. adding sine wave pattern to dynamic float


  • Subject: logic problem. adding sine wave pattern to dynamic float
  • From: Chunk 1978 <email@hidden>
  • Date: Fri, 5 Feb 2010 09:02:43 -0500

this is mostly a logic problem, so i apologize for my question not
being cocoa specific.

i'm attempting to add my own continuous pitch variation effect
(vibrato) by assigning my sound's pitch to the path of a sine wave.
this is my callback method, which is repeating every 1/30 of a second.

- (void)vibratoCallBack:(NSTimer *)timer
	{
	float newPitch = 0.025 * sin(kDegreesToRadians(vibratoDegreeIncrements));
	self.pitch += newPitch;

	vibratoDegreeIncrements += kVibratoDegreeIncrements;  //this value is 45
	}

the default pitch is set at 1.0, so the above outputs the following
sine wave cycle:

Wrong Pitch: 1.000000
Wrong Pitch: 1.017678
Wrong Pitch: 1.042678
Wrong Pitch: 1.060355
Wrong Pitch: 1.060355
Wrong Pitch: 1.042678
Wrong Pitch: 1.017678
Wrong Pitch: 1.000000

however, if you look at those numbers they are not much of a sine
wave.  the reason, as far as i can see, is that self.pitch is adding
itself along with the sine wave increments.  i would like the pitch to
be movable while the vibrato effect is happening, but i can't seem to
find a way.  below is the proper sine wave output that i would like to
add to the current pitch:

Correct Pitch: 0.000000
Correct Pitch: 0.017678
Correct Pitch: 0.025000
Correct Pitch: 0.017678
Correct Pitch: 0.000000
Correct Pitch: -0.017678
Correct Pitch: -0.025000
Correct Pitch: -0.017678
Correct Pitch: -0.000000

therefore, if the pitch is at 1.0, i would like the output to look like this:

Desired Pitch: 1.000000
Desired Pitch: 1.017678
Desired Pitch: 1.025000
Desired Pitch: 1.017678
Desired Pitch: 1.000000
Desired Pitch: 0.917678
Desired Pitch: 0.925000
Desired Pitch: 0.917678
Desired Pitch: 1.000000

help would be greatly appreciated.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: logic problem. adding sine wave pattern to dynamic float
      • From: Graham Cox <email@hidden>
    • Re: logic problem. adding sine wave pattern to dynamic float
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: pdfkit - changing background color
  • Next by Date: Re: using a tableview delegate
  • Previous by thread: Re: using a tableview delegate
  • Next by thread: Re: logic problem. adding sine wave pattern to dynamic float
  • Index(es):
    • Date
    • Thread