|
Post by nathanmyersc on Apr 6, 2024 5:54:49 GMT
You should program it so its possible to accept multiple frequencies and a count for how many samples before frequency change. So that you can interweave as many frequencies as you want into your wav fle.
|
|
|
Post by AnthroHeart on Apr 6, 2024 13:00:59 GMT
You should program it so its possible to accept multiple frequencies and a count for how many samples before frequency change. So that you can interweave as many frequencies as you want into your wav fle. That might be interesting but I'm not sure how many will need that feature. Would it be like one frequency per channel all playing at the same time? Or one frequency after the other? Like frequencies separated by commas?
And would it go gracefully from one frequency to the next or just jump to it? If going gracefully, how many seconds to take to transition?
|
|
|
Post by AnthroHeart on Apr 6, 2024 13:21:44 GMT
You should program it so its possible to accept multiple frequencies and a count for how many samples before frequency change. So that you can interweave as many frequencies as you want into your wav fle. Pi said this:
As a general rule of thumb, though, a transition time between 0.1 and 0.5 seconds is often considered smooth and natural-sounding. A shorter transition time (e.g., 0.1 seconds) will result in a faster, more noticeable change between frequencies, while a longer transition time (e.g., 0.5 seconds) will produce a more gradual, subtle shift.
|
|
|
Post by nathanmyersc on Apr 6, 2024 13:40:53 GMT
You should program it so its possible to accept multiple frequencies and a count for how many samples before frequency change. So that you can interweave as many frequencies as you want into your wav fle. Pi said this:
As a general rule of thumb, though, a transition time between 0.1 and 0.5 seconds is often considered smooth and natural-sounding. A shorter transition time (e.g., 0.1 seconds) will result in a faster, more noticeable change between frequencies, while a longer transition time (e.g., 0.5 seconds) will produce a more gradual, subtle shift.
Ive got it so t accepts a string of numbers seperated by commas and it asks the rate of change of frequency you want. i set it to about 50000 samples. so when i use my special application and have the sample rate of 1764000 it changes about every 35th of a second. creates some interesting songs if you order your frequencnies right. i think its helpful for you personally. because you could craft better tools. like find frequencies that are for a certain subject and imbue your intentions on those. using about 21 frequencies for the pituitary gland to stimulate HGH. check out Intuition Sharpener on my patreon it uses this ne wtechniqe.
|
|
|
Post by AnthroHeart on Apr 6, 2024 13:45:02 GMT
If you're converting a text or image to a WAV, wouldn't you want the freqs to be evenly distributed?
If you specify 50000 samples for each frequency, there might be WAV samples left over beyond your specified freqs, or you might specify too many for the WAV.
It might be better to specify your freqs, and then let them be evenly distributed.
Or somehow specify what % of the WAV you want for each freq, but you'd have to have them add to 100%.
|
|
|
Post by nathanmyersc on Apr 6, 2024 13:52:09 GMT
If you're converting a text or image to a WAV, wouldn't you want the freqs to be evenly distributed? If you specify 50000 samples for each frequency, there might be WAV samples left over beyond your specified freqs, or you might specify too many for the WAV. It might be better to specify your freqs, and then let them be evenly distributed. Or somehow specify what % of the WAV you want for each freq, but you'd have to have them add to 100%. Could be a good idea i like messing around to see how it sounds intuition sharpener sounds robotic and cool.
|
|
|
Post by nathanmyersc on Apr 6, 2024 13:55:20 GMT
Heres how i did it if you want to mess around with it.
Write Data Chunk You can just take the pertinant parts where it changes the frequencies and loads the variables
const double M_PI = 3.141592653589793238462643383279502884197;
const double PIX2 = 2.0 * M_PI;
std::array<double,256> amplitude_lookup; std::ostringstream threadSafeCoutOutputStream;
void writeDataChunkMultipleFrequencies(ofstream& wavFile,const uint32_t dataCyclesToWrite, const std::string& textToTransmit)
{
threadSafeCout("ENTERING DATA CHUNK WRITING FUNCTION\n");
const uint64_t dataChunkSizePos = writeDataChunkHeader(wavFile);
const std::string filteredText = removeNonAlphanumeric(textToTransmit);
const auto [minOrd, maxOrd] = findMinMaxASCII(filteredText);
const short min_ascii = minOrd;
const short ascii_range = maxOrd - minOrd;
double phaseIncrement = (2.0 * M_PI * frequency) / sampleRate;
double sampleFrequency = (sampleRate / frequency);
const size_t bufferSize = 1024 * 1024 * numChannels * (bitsPerSample / 8); // Adjust the buffer size as needed
std::vector<double> interpolationFactorConstantX2(frequencyChangeRate,0);
for(uint32_t i = 0;i<frequencyChangeRate;++i)
interpolationFactorConstantX2[i] = (fmod(i,sampleFrequency)/sampleFrequency) * 2;
for (uint32_t ascii_value = 0; ascii_value < 256; ++ascii_value)
amplitude_lookup[ascii_value] = (ascii_value - min_ascii) / ascii_range;;
double phase = 0.0; // Phase accumulator
uint32_t frequencyIterator = 0; uint8_t lowFrequencyBoost = (frequency <= 10 && volume_level > 0)?1 :0;
std::vector<char> frames; frames.reserve(bufferSize); // Reserve memory upfront
for (uint32_t i = 0; i < dataCyclesToWrite; ++i) { ///NUMBER OF TIMES TO WRITE 2 BYTES OF SILENCE INTO DATA CHUNK
if(i % frequencyChangeRate == 0)
{
frequency = frequencies[++frequencyIterator % frequencies.size()];
phaseIncrement = (2.0 * M_PI * frequency) / sampleRate;
sampleFrequency = (sampleRate / frequency);
for(uint32_t x= 0;x<frequencyChangeRate;++x)
interpolationFactorConstantX2[x] = (fmod(x,sampleFrequency)/sampleFrequency) * 2;
lowFrequencyBoost = (frequency <= 10 && volume_level > 0)?1 :0;
}
// 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%interpolationFactorConstantX2.size()]) - 1.0;
phase = fmod(phase + phaseIncrement, PIX2);
long long int sample_value = 0;
if (smoothing == 0.0) {
sample_value = amplitude_interpolated * sin(phase) * sampleMax;
} else {
double trendingWave = smoothing * sin(phase);
double smoothedAmplitude = (1.0 - smoothing) * amplitude_interpolated;
sample_value = (trendingWave + smoothedAmplitude) * sampleMax;
}
sample_value *= (volume_level + lowFrequencyBoost);
for (uint32_t j = 0; j < numChannels; ++j)
insertSample(frames,sample_value);
if (frames.size() >= bufferSize || i == dataCyclesToWrite - 1) {
wavFile.write(frames.data(), frames.size());
frames.clear();
}
if (i % 100000 == 0 || i == dataCyclesToWrite - 1) {
threadSafeCoutOutputStream << "\rProgress: " << std::fixed << std::setprecision(2)
<< static_cast<double>(i) / static_cast<double>(dataCyclesToWrite) * 100.0
<< "% Samples Written: " << std::to_string(i) << " \r" << std::flush;
threadSafeCout(threadSafeCoutOutputStream.str());
threadSafeCoutOutputStream.str(""); // Clear the stream
}
}
endDataChunk(dataChunkSizePos,wavFile);
}
And to gather the frequencies from the user inputted string i used
void collectFrequencies() {
std::string input;
while (true) {
// Prompt the user to input frequencies
std::cout << "Enter frequencies separated by commas or commas and a blank space: ";
std::getline(std::cin, input);
// Check if input is valid (contains only numerals, white spaces, and commas)
bool isValid = true;
for (char c : input) {
if (!std::isdigit(c) && !std::isspace(c) && c != ',' && c != '.') {
isValid = false;
break;
}
}
bool hasNumeral = false;
if (isValid) {
for (char c : input) {
if (std::isdigit(c)) {
hasNumeral = true;
break;
}
}
} else {
std::cout << "Invalid input. Please enter only numerals, white spaces, and commas." << std::endl;
}
if(hasNumeral)
break;
}
// Split the input string by commas and process each part
std::string token; std::istringstream iss(input);
while (std::getline(iss, token, ',')) {
// Remove any leading or trailing white spaces
token.erase(token.find_last_not_of(" \n\r\t") + 1);
token.erase(0, token.find_first_not_of(" \n\r\t"));
// Convert token to double and add to frequencies vector
double frequency = std::stod(token);
frequencies.push_back(frequency);
}
std::cout << "Number Of Frequencies: " << frequencies.size() << "\n";
std::cout << "Frequencies:";
for (double frequency : frequencies) {
std::cout << " " << frequency;
}
std::cout << "\n";
}
|
|
|
Post by AnthroHeart on Apr 6, 2024 13:55:46 GMT
If you're converting a text or image to a WAV, wouldn't you want the freqs to be evenly distributed? If you specify 50000 samples for each frequency, there might be WAV samples left over beyond your specified freqs, or you might specify too many for the WAV. It might be better to specify your freqs, and then let them be evenly distributed. Or somehow specify what % of the WAV you want for each freq, but you'd have to have them add to 100%. Could be a good idea i like messing around to see how it sounds intuition sharpener sounds robotic and cool. I'm not clear on what you mean here. I think specifying a percentage for each frequency might be better.
I don't know if robotic and such would be popular.
I might take on this project if others want it too.
|
|
|
Post by AnthroHeart on Apr 6, 2024 13:56:53 GMT
It seems you have code already. Would you still need me to implement any changes to my existing WAV generators?
|
|
|
Post by AnthroHeart on Apr 6, 2024 14:07:48 GMT
I put your code into Claude to analyze and it gave this feedback:
Regarding the transition between frequencies, the code attempts to make the transition graceful by using interpolation. It calculates an interpolation factor (interpolationFactorConstantX2) based on the current sample position within the current frequency's period. This interpolation factor is used to interpolate the amplitude between the current character's amplitude and the next character's amplitude.
const double amplitude_interpolated = ((amplitude_current + (amplitude_next - amplitude_current)) * interpolationFactorConstantX2) - 1.0; This interpolation helps to smoothly transition the amplitude between characters as the frequency changes.
However, it's important to note that the code does not perform any explicit phase matching or synchronization when changing frequencies. The phase accumulator (phase) is simply updated based on the new frequency's phase increment, which may introduce discontinuities in the waveform at the transition points.
phase = fmod(phase + phaseIncrement, PIX2);
If you want to ensure a completely smooth transition between frequencies, you would need to modify the code to handle phase synchronization at the transition points. This could involve techniques like phase resetting, phase matching, or crossfading between the old and new frequencies.
In summary, the code changes the frequency every frequencyChangeRate samples and attempts to make the transition graceful by interpolating the amplitude. However, it does not guarantee a perfectly smooth transition between frequencies due to the lack of explicit phase synchronization.
|
|
|
Post by nathanmyersc on Apr 6, 2024 14:08:30 GMT
It seems you have code already. Would you still need me to implement any changes to my existing WAV generators? I was just sharing a cool break through i found. kind of like how that HGH sound i showed you was good i think having frequencies multiple of them imbued with our intentiosn is good. For some reason i can never get the exe of the imagetowavwriter to make a usable wav file wont play for some reason not sure why.
|
|
|
Post by nathanmyersc on Apr 6, 2024 14:10:16 GMT
I put your code into Claude to analyze and it gave this feedback: Regarding the transition between frequencies, the code attempts to make the transition graceful by using interpolation. It calculates an interpolation factor (interpolationFactorConstantX2) based on the current sample position within the current frequency's period. This interpolation factor is used to interpolate the amplitude between the current character's amplitude and the next character's amplitude. const double amplitude_interpolated = ((amplitude_current + (amplitude_next - amplitude_current)) * interpolationFactorConstantX2) - 1.0; This interpolation helps to smoothly transition the amplitude between characters as the frequency changes. However, it's important to note that the code does not perform any explicit phase matching or synchronization when changing frequencies. The phase accumulator (phase) is simply updated based on the new frequency's phase increment, which may introduce discontinuities in the waveform at the transition points. phase = fmod(phase + phaseIncrement, PIX2); If you want to ensure a completely smooth transition between frequencies, you would need to modify the code to handle phase synchronization at the transition points. This could involve techniques like phase resetting, phase matching, or crossfading between the old and new frequencies. In summary, the code changes the frequency every frequencyChangeRate samples and attempts to make the transition graceful by interpolating the amplitude. However, it does not guarantee a perfectly smooth transition between frequencies due to the lack of explicit phase synchronization. I ponder whether this would make it sound better. phase resetting would be an easy option. But i felt like continuing from where i was was the best option but i havent a clue.
|
|
|
Post by AnthroHeart on Apr 6, 2024 14:37:26 GMT
It seems you have code already. Would you still need me to implement any changes to my existing WAV generators? I was just sharing a cool break through i found. kind of like how that HGH sound i showed you was good i think having frequencies multiple of them imbued with our intentiosn is good. For some reason i can never get the exe of the imagetowavwriter to make a usable wav file wont play for some reason not sure why. See if this produces a playable WAV. It works for me. ChatGPT4 helped me make the update:
|
|
|
Post by nathanmyersc on Apr 6, 2024 14:38:38 GMT
I was just sharing a cool break through i found. kind of like how that HGH sound i showed you was good i think having frequencies multiple of them imbued with our intentiosn is good. For some reason i can never get the exe of the imagetowavwriter to make a usable wav file wont play for some reason not sure why. See if this produces a playable WAV. It works for me. ChatGPT4 helped me make the update:
Thanks i added crossfading and phase matching as an option i can use to see if it produces a better sound whilst maintaining the ability to do nothing and il check this version out maybe i just gotta compile it myself no idea why it always fails to play. #edit it worked that time. Try my HGH.bmp image with 645hz i think it makes me feel masculine as fuck. thats prelimiary but it is giving me that feeling.
|
|
|
Post by reden on Apr 6, 2024 14:38:56 GMT
Pi said this:
As a general rule of thumb, though, a transition time between 0.1 and 0.5 seconds is often considered smooth and natural-sounding. A shorter transition time (e.g., 0.1 seconds) will result in a faster, more noticeable change between frequencies, while a longer transition time (e.g., 0.5 seconds) will produce a more gradual, subtle shift.
Ive got it so t accepts a string of numbers seperated by commas and it asks the rate of change of frequency you want. i set it to about 50000 samples. so when i use my special application and have the sample rate of 1764000 it changes about every 35th of a second. creates some interesting songs if you order your frequencnies right. i think its helpful for you personally. because you could craft better tools. like find frequencies that are for a certain subject and imbue your intentions on those. using about 21 frequencies for the pituitary gland to stimulate HGH. check out Intuition Sharpener on my patreon it uses this ne wtechniqe. You should have all the frequencies running at once instead of giving X timeslices to each. That way it's better. VibesWorld in Youtube does it that way I think.
|
|