|
Post by nathanmyersc on Apr 2, 2024 3:58:17 GMT
No, that's bad as the nyquist (usable) frequency is only 5000, which is too low (anything beneath 11000 is too low). We are trying to avoid low frequencies as they could harm spiritual progress. Anyway, changing the sampling rate to nonstandard (and even worse, low) numbers was rather useless as everyone even before this tool just used standard rates and are happy. The energy was feelable according to you. Standard rates: 44100 48000 96000 192000 384000 655350 (for flac) You can go higher or anything you want as WAV, but you shouldn't go lower than 44100. Ok, I updated the program to not allow less than 44100 for sampling rate. Glad you could use the vastly superior c++ language way faster.
|
|
|
Post by AnthroHeart on Apr 2, 2024 4:20:49 GMT
Ok, I updated the program to not allow less than 44100 for sampling rate. Glad you could use the vastly superior c++ language way faster. I didn't like having to remove your big list of intentions, but it was a bit confusing when I was trying to remove non-alphanumeric characters.
I made my WAV Converter so it doesn't remove non-alphanumeric characters.
Reden gave me an idea to try to convert UTF-8 Unicode to WAV. I have a UTF-8 sample with chinese language I'm going to work on converting.
|
|
|
Post by nathanmyersc on Apr 2, 2024 4:22:29 GMT
Glad you could use the vastly superior c++ language way faster. I didn't like having to remove your big list of intentions, but it was a bit confusing when I was trying to remove non-alphanumeric characters.
I made my WAV Converter so it doesn't remove non-alphanumeric characters.
Reden gave me an idea to try to convert UTF-8 Unicode to WAV. I have a UTF-8 sample with chinese language I'm going to work on converting.
Beats asking GPT how to do what you were trying to do in c++ hed give you the run around for days. HAHA. Sweet man i wish i knew how to make the console accept sanskrit and other languages. could be more powerful to affirm n several languages at once.
|
|
|
Post by AnthroHeart on Apr 2, 2024 4:26:25 GMT
The only issue with Unicode is possible outliers, where one character has a way higher value than the others, and it flattens the audio for the rest of the characters and produces a sharp peak for that one. There are probably ways to do statistics or averaging. That's why I did trend waves to smooth out the audio. But I still have to figure out how to handle outliers.
|
|
|
Post by nathanmyersc on Apr 2, 2024 4:57:05 GMT
The only issue with Unicode is possible outliers, where one character has a way higher value than the others, and it flattens the audio for the rest of the characters and produces a sharp peak for that one. There are probably ways to do statistics or averaging. That's why I did trend waves to smooth out the audio. But I still have to figure out how to handle outliers. Yeah make a version that takes the AVERAGE of all the values and centers the noise around that average. give less weight to outliers. ask chat gpt about it. Like each character has the same weight. So an outlier would have less effect on the overall max-min amplitude range. Like an outlier would be higher in amplitude but you could clip its effect on the rest of the characters. Say if your normal ascii is n the range of -2 to 132 and you got this 15543 number. You could clip taht number at say 256. So it recieves an amplitude equivalent to it being 256. and that would stop much of the loss of sound of hte others. But you could fine tune it bette rthan that im sure.
|
|
|
Post by nathanmyersc on Apr 2, 2024 10:34:05 GMT
Heres an optimized writeDataChunk Section based upon what you gave me.
uint32_t writeDataChunkHeader(ofstream& wavFile)
{
wavFile.write("data", 4); ///WRITING THE HEADER FOR THE DATA CHUNK OF THE WAV FILE
const uint32_t dataChunkSizePos = wavFile.tellp(); ///CAPTURING THE POSITION OF THE DATA CHUNK SIZE ELEMENT
wavFile.write(reinterpret_cast<const char*>(&headerChunkSize), sizeof(headerChunkSize)); ///WRITING THE PLACEHOLDER VALUE FOR THE SIZE OF THE DATA CHUNK
return dataChunkSizePos;
}
void endDataChunk(const uint32_t dataChunkSizePos,ofstream& wavFile)
{
uint32_t actualDataSize =( wavFile.tellp() - dataChunkSizePos ) - 4; /// CALCULATE DATA CHUNK SIZE
if (actualDataSize% 2 != 0) { /// IF OUR DATA IS NOT DIVISIBLE BY 2 WE ADD AN EXTRA BYTE AT THE END
uint8_t paddingByte = 0;
wavFile.write(reinterpret_cast<const char*>(&paddingByte), sizeof(paddingByte));
actualDataSize += 1;
} ///RECORD THE END OF FILE POSITION
const uint32_t actualFileSize = wavFile.tellp(); ///CALCULATE FULL FILE SIZE
wavFile.seekp(dataChunkSizePos,ios::beg); /// SEEK DATA CHUNK SIZE ELEMENT
wavFile.write(reinterpret_cast<const char*>(&actualDataSize),4); /// WRITE PROPER DATA CHUNK SIZE IN ELEMENTS POSITION
wavFile.seekp(0,ios::end);
}
const double M_PI = 3.141592653589793238462643383279502884197;
const double PIX2 = 2.0 * M_PI;
std::array<float,256> amplitude_lookup;
void writeDataChunk(ofstream& wavFile,const uint32_t numOfDataCyclesToWrite, const std::string textToTransmit)
{
const uint32_t dataChunkSizePos = writeDataChunkHeader(wavFile);
const std::string filteredText = removeNonAlphanumeric(textToTransmit);
const auto [minOrd, maxOrd] = findMinMaxASCII(filteredText);
const int min_ascii = minOrd;
const int max_ascii = maxOrd;
const int ascii_range = maxOrd - minOrd;
const double phaseIncrement = (2.0 * M_PI * frequency) / sampleRate;
const double sampleFrequency = (sampleRate / frequency);
const double interpolationConstant = (static_cast<double>(sampleFrequency)) / (sampleFrequency);
const size_t bufferSize = 1024 * 1024 * numChannels * (bitsPerSample / 8); // Adjust the buffer size as needed
std::vector<float> interpolationFactorConstantX2(numOfDataCyclesToWrite,0);
for(int i = 0;i<numOfDataCyclesToWrite;++i)
interpolationFactorConstantX2[i] = fmod(i,interpolationConstant) * 2;
for (int ascii_value = 0; ascii_value < 256; ++ascii_value)
amplitude_lookup[ascii_value] = (ascii_value - min_ascii) / ascii_range;;
double phase = 0.0; // Phase accumulator
std::vector<char> frames;
for (uint32_t i = 0; i < numOfDataCyclesToWrite; ++i) { ///NUMBER OF TIMES TO WRITE 2 BYTES OF SILENCE INTO DATA CHUNK
// Calculate the character index and sample index within the character
const long char_index = fmod((i / sampleFrequency), filteredText.size());
const char current_char = filteredText[char_index];
const char next_char = filteredText[(char_index + 1) % filteredText.size()];
const double amplitude_current =amplitude_lookup[ord(current_char)];
const double amplitude_next =amplitude_lookup[ord(next_char)];
const double amplitude_interpolated = (amplitude_current + (amplitude_next - amplitude_current) * interpolationFactorConstantX2[i]) - 1.0;
if ((phase += phaseIncrement) > PIX2) {
phase -= PIX2;
}
const long long int sample_value = (smoothing == 0.0 ?amplitude_interpolated * sin(phase) * sampleMax
:(( ( smoothing * sin(phase) ) + ( (1.0 - smoothing) * amplitude_interpolated ) ) * sampleMax ) );
for (int j = 0; j < numChannels; ++j)
insertSample(frames,sample_value);
if (frames.size() >= bufferSize || i == numOfDataCyclesToWrite - 1) {
wavFile.write(frames.data(), frames.size());
frames.clear();
}
if (i % 100000 == 0 || i == numOfDataCyclesToWrite - 1) {
std::cout << "\rProgress: " << std::fixed << std::setprecision(2) << static_cast<float>(i) / static_cast<float>(numOfDataCyclesToWrite) * 100.0f << "% Samples Written: " << std::to_string(i) << " \r" << std::flush;
}
}
endDataChunk(dataChunkSizePos,wavFile);
}
|
|
|
Post by AnthroHeart on Apr 2, 2024 12:37:22 GMT
How is it optimized?
|
|
|
Post by nathanmyersc on Apr 2, 2024 13:33:55 GMT
By precompiling as much math as possible by removing redundant lines. by shrinking the amount of lines of code to accomlish the same thing.
|
|
|
Post by reden on Apr 2, 2024 14:36:27 GMT
The only issue with Unicode is possible outliers, where one character has a way higher value than the others, and it flattens the audio for the rest of the characters and produces a sharp peak for that one. There are probably ways to do statistics or averaging. That's why I did trend waves to smooth out the audio. But I still have to figure out how to handle outliers. Yeah make a version that takes the AVERAGE of all the values and centers the noise around that average. give less weight to outliers. ask chat gpt about it. Like each character has the same weight. So an outlier would have less effect on the overall max-min amplitude range. Like an outlier would be higher in amplitude but you could clip its effect on the rest of the characters. Say if your normal ascii is n the range of -2 to 132 and you got this 15543 number. You could clip taht number at say 256. So it recieves an amplitude equivalent to it being 256. and that would stop much of the loss of sound of hte others. But you could fine tune it bette rthan that im sure. You could clip it at say 512 so that volume loss for the others is only 50%, which isn't that much at 100% volume given what is being made here.
|
|
|
Post by AnthroHeart on Apr 2, 2024 14:47:11 GMT
Yeah make a version that takes the AVERAGE of all the values and centers the noise around that average. give less weight to outliers. ask chat gpt about it. Like each character has the same weight. So an outlier would have less effect on the overall max-min amplitude range. Like an outlier would be higher in amplitude but you could clip its effect on the rest of the characters. Say if your normal ascii is n the range of -2 to 132 and you got this 15543 number. You could clip taht number at say 256. So it recieves an amplitude equivalent to it being 256. and that would stop much of the loss of sound of hte others. But you could fine tune it bette rthan that im sure. You could clip it at say 512 so that volume loss for the others is only 50%, which isn't that much at 100% volume given what is being made here. I did a 180kB chinese document UTF-8 to WAV and it didn't need averaging. It sounded fine.
Thing is if you had a document one character with the highest possible UTF-8 value, and a lot of other data in the middle values, it would flatten out the middle data. But that is unusual, but a good thought experiment. Just throw the highest UTF-8 character into your UTF-8 document, and see how it changes it.
|
|
|
Post by AnthroHeart on Apr 4, 2024 23:48:41 GMT
I updated the Unicode to WAV Converter, Image to WAV Converter, and WAV Repeater. They were clipping audio when set to 100% volume, so I set max to 99%. Link to update: intention-repeater.sourceforge.io/
|
|
|
Post by AnthroHeart on Apr 6, 2024 23:00:55 GMT
The WAV Repeater produces shorter audios for higher frequencies.
Do we want to reflect a certain length of audio, rather than # of repetitions?
|
|
|
Post by AnthroHeart on Apr 6, 2024 23:31:48 GMT
The WAV Repeater produces shorter audios for higher frequencies.
Do we want to reflect a certain length of audio, rather than # of repetitions?
I'm going to keep it as it is. The audios can be made longer in Audacity to line up.
|
|
|
Post by AnthroHeart on Apr 7, 2024 7:14:25 GMT
I updated the 2 WAV Repeater Programs. The Text to WAV Repeater. The Unicode to WAV Repeater.
Now they tell you how big a WAV file will be before you create it, so there are no unexpected surprises.
Link to the .zip which contains updates in my signature.
I updated all to v1.2
|
|
|
Post by AnthroHeart on Apr 7, 2024 12:16:36 GMT
Ok, updated to v1.3. It was not creating the WAV when a user chose "y" to continue. So had to fix.
Feel free to download WAV Converter and 2 WAV Repeaters from the zip in my signature.
|
|