|
Post by nathanmyersc on Mar 29, 2024 7:23:50 GMT
Totally amplitude width is what i call the value that corresponds to a sample. i guess i could call it sampleWidth. 4 means 32-bits yeah 8 bits to a byte. I changed it so we were using the whole 32 bits because the 32767 is only for 2 bytes not 4. I updated your code to allow you to specify the # of samples/steps between each sample value, from two neighboring pixel values.
So it doesn't jump between sample values faster than the speaker can respond.
It defaults to 1, which shouldn't change what you have.
I tried 10 steps and 100 steps for interesting results. So it's more graceful in going between pixel values. You might want to check the code.
Thanks i modified it for text files as well. also made both python scripts give each channel the same data.
|
|
|
Post by AnthroHeart on Mar 29, 2024 12:47:04 GMT
I updated your code to allow you to specify the # of samples/steps between each sample value, from two neighboring pixel values.
So it doesn't jump between sample values faster than the speaker can respond.
It defaults to 1, which shouldn't change what you have.
I tried 10 steps and 100 steps for interesting results. So it's more graceful in going between pixel values. You might want to check the code.
Thanks i modified it for text files as well. also made both python scripts give each channel the same data. For the Text one you have:
if amplitudewidth == 4: sample_current = max(-2147483648, min(sample_current, 2147483647)) next_sample = max(-2147483648, min(sample_current, 2147483647)) else: # assuming 2 bytes wide sample_current = max(-32768, min(sample_current, 32767)) next_sample = max(-32768, min(sample_current, 32767))
You could use a sampleMax variable to hold either 32767 or 2147483647, and use sampleMax + 1 when needed to simplify the code.
You have the same code for sample_current and next_sample. Should they be different?
Also, if you took the ASCII value range between the lowest and highest values in the text you enter, and used that as a range to map to the full range of the WAV, would that be better? It might give you full use of what you are writing, rather than just a narrow band of the ASCII possible values. Like only giving you 26*2 possible values plus punctuation instead of the full 255 possible ASCII values.
|
|
|
Post by nathanmyersc on Mar 30, 2024 11:10:48 GMT
i tried that with this code. makes it very quiet. correct me where im wrong i askd chat gpt for some help doing it.
|
|
|
Post by AnthroHeart on Mar 30, 2024 12:26:12 GMT
i tried that with this code. makes it very quiet. correct me where im wrong i askd chat gpt for some help doing it. I got some help from Claude, but ended up figuring it out on my own.
I find 100 samples/character to be good.
This smoothly goes between each character, whether it flips negative or positive wav sample value. It looks like a triangle wave.
I wonder if we can convert this to a sine wave.
Would a sine wave be as energetically optimal as the triangle wave?
This is how the waveform looks (triangle wave) from the output wav:
|
|
|
Post by AnthroHeart on Mar 30, 2024 12:51:32 GMT
This one outputs a sine wave instead of a triangle wave:
I find it to be better audio. Not as sharp.
It doesn't output to 100% volume though. I think that's fine though.
The sine waveform:
|
|
|
Post by AnthroHeart on Mar 30, 2024 13:27:22 GMT
reden said: "No dont use triangle wave or square wave or sawtooth wave. They're impure corruptions of Sine waves." So might be better to use sine wave for this.
|
|
|
Post by AnthroHeart on Mar 30, 2024 13:48:51 GMT
Here are the latest Text to Wav Sine and Image to Wav Sine code, since Sine is much more beneficial:
Here's an mp3 I created with Nathan's Marijuana picture, as Sine. It's a little loud, but not max volume: Output_Sine_767500.mp3 (73.4 KB)
|
|
|
Post by AnthroHeart on Mar 30, 2024 16:00:39 GMT
|
|
|
Post by AnthroHeart on Mar 30, 2024 18:48:09 GMT
I updated the Repeater WAV to allow for frequencies in a text file as well as specified text.
So you can choose like 532Hz for the rate of each character.
Here is my post:
|
|