I want to create composite audio test signals in a numpy array. I need the values to be integers rounded to the nearest whole number. Secondly I want to add random noise or dither.
You can see below the code I use currently. This should comprise 24-bit integers (if I have got this right) even though it is stored in 32-bit integer words (to match pcm audio samples which are commonly stored this way).
In this example the first sine wave tone would be 1000.2Hz at half peak value (-6dBfs). There are two more sine wave components here though in practice it could contain any number them. I now want to add some dither. This would be calculated as a random value for each ordinate in the array. It would add a small randomly generated value of something like between + and - 0.5 peak to each array element (each audio sample).
x = np.linspace(0, 48000, 48000, False, dtype = "int32")
pcm_array:np.dtype(np.int32) =
(1073741824 * np.sin(((x + 0) * 1000.2 / 48000) * 2 * np.pi)) +
(10737418.24 * np.sin(((x + 0) * 1049.7 / 48000) * 2 * np.pi)) +
(1.073741824 * np.sin(((x + 0) * 1200.5 / 48000) * 2 * np.pi))
My code seems to work fine but does not include the random 'dither' component. Can someone let me know how to do that - and also reassure me that I will end up with 24-bit resolution integers.