Sine wave amplitude modulation - Analysis using Audacity I am trying amplitude modulation in C++ on a sine wave which is a 1000 Hz sine wave sampled at 48000 Hz. The original sine wave is like this (In Audacity) - 



When I basically double the amplitude for each sample, it works except for the flipping up of the extremities - 



When I multiple each sample with 4, this is what I get - 



Why is this the case, when the equations that I am using in the algorithm don't have anything of this sort? What if I want to remove this 'error'? 

P. S. When I import the .raw data, I am using Signed 32-bit PCM encoding, Big-endian Byte order and single channel, with zero offset and 48kHz sample rate.
Your samples have a finite bitwidth. For example, assume your samples have 16 bit width; if you increase their amplitude beyond what these 16 bit can represent, you end up with an overflow.

In case your audio samples being signed integers, that overflow typically first manifests as a sign inversion – exactly what you're seeing here. (That's because only the lower 15 bits in your 16 bit signed integer are actually the number – the uppest bit is the sign; you shift a 1 there, the result becomes a negative number in 2-complement represenation.)

This isn't a limitation of audio processing only – in fact, integer limits is something basically (nearly) every programmer needs to be (slightly) aware of. Your number variables can't hold arbitrarily large values!