|
Post by nathanmyersc on Sept 18, 2024 2:44:14 GMT
std::unordered_map<char, int> create_lookup_table_ultra(int maxamp, int minamp) {
// Create an empty unordered_map for the lookup table
std::unordered_map<char, int> lookup_table;
// Populate the lookup table with symbols and their corresponding amplitudes
for (int symbol = 0; symbol < 256; ++symbol) {
if (symbol % 2 == 0) {
// Map even ASCII values to the range [minamp, maxamp]
int adjusted_value = static_cast<int>((static_cast<double>(symbol) / 255) * (maxamp - minamp)) + minamp;
// Clamp adjusted_value to the range [minamp, maxamp]
adjusted_value = std::max(minamp, std::min(adjusted_value, maxamp));
lookup_table[static_cast<char>(symbol)] = adjusted_value;
} else {
// Map odd ASCII values to the range [minamp, maxamp]
int adjusted_value = static_cast<int>((static_cast<double>(symbol) / 255) * (maxamp - minamp)) + minamp;
// Clamp adjusted_value to the range [minamp, maxamp]
adjusted_value = std::max(minamp, std::min(adjusted_value, maxamp));
lookup_table[static_cast<char>(symbol)] = adjusted_value;
}
}
return lookup_table;
}
void writeDataChunkNoWaveForm(ofstream& wavFile, const uint32_t dataCyclesToWrite, const std::string& filteredText)
{
// Set frequency to be in the ultrasonic range (21 kHz)
double ultrasonicFrequency = 21922.0; // 21 kHz
// Ensure sampleRate is 44100 Hz (no need to adjust since it's suitable for ultrasonic frequencies up to 22.05 kHz)
if (sampleRate != 44100) {
sampleRate = 44100;
}
const uint64_t dataChunkSizePos = writeDataChunkHeader(wavFile);
threadSafeCout("ENTERING DATA CHUNK WRITING FUNCTION\n");
// Create a vector to store the values for each ASCII character
std::unordered_map<char, int> values = create_lookup_table_ultra(255, -255);
const size_t bufferSize = 1024 * 1024 * numChannels * (bitsPerSample / 8); // Adjust buffer size as needed
std::vector<char> frames;
frames.reserve(bufferSize); // Reserve memory upfront
for (uint32_t i = 0; i < dataCyclesToWrite; ++i) {
// Generate ultrasonic waveform using the specified frequency
const int32_t value = (values[filteredText[i%filteredText.size()]] + ultrasonicFrequency) * volume_level;
// Insert samples into the frames vector
for (uint32_t j = 0; j < numChannels; ++j) {
insertSample(frames, 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);
threadSafeCout("EXITING DATA CHUNK WRITING FUNCTION\n");
}
|
|
|
Post by AnthroHeart on Sept 18, 2024 9:57:23 GMT
Thank you for posting. Can you explain what it does and how to use or compile it?
|
|
|
Post by reden on Sept 18, 2024 13:01:34 GMT
Thank you for posting. Can you explain what it does and how to use or compile it? Sure! Here's a summary of the provided code and an explanation of what it does: ### Summary: The code is written in C++ and contains a function to create a lookup table mapping ASCII characters to amplitude values, as well as a function to write an ultrasonic waveform into a WAV file. ### Details: 1. **Function `create_lookup_table_ultra`**: - **Input Parameters**: `maxamp` (maximum amplitude), `minamp` (minimum amplitude) - **Output**: Returns an unordered map (`lookup_table`) where each ASCII character (from 0 to 255) is mapped to an adjusted amplitude value. - **Logic**: - Each ASCII value (even or odd) is adjusted to be within the range of `minamp` to `maxamp`. - The adjusted values are calculated based on the normalized ASCII value and clamped within the specified amplitude range. 2. **Function `writeDataChunkNoWaveForm`**: - **Input Parameters**: `ofstream& wavFile` (output WAV file stream), `dataCyclesToWrite` (number of data cycles to write), `filteredText` (text to encode in the waveform). - **Output**: Writes data to the provided WAV file. - **Logic**: - The function targets ultrasonic frequencies (21 kHz). - Ensures the sample rate is set to 44100 Hz, suitable for ultrasonic frequencies. - Calls `create_lookup_table_ultra` to generate a lookup table with amplitude values. - Uses a buffer to hold frame data temporarily and writes it to the WAV file periodically. - Iterates over the `dataCyclesToWrite`, generating ultrasonic waveforms for each character in the `filteredText`. - Updates progress to the console and clears the buffer after writing. ### Usage and Compilation: To use and compile this code: - Include the appropriate headers for file I/O (`<fstream>`), unordered map (`<unordered_map>`), vector (`<vector>`), and threading/console output if necessary. - Make sure to define auxiliary functions like `writeDataChunkHeader`, `insertSample`, `endDataChunk`, and `threadSafeCout` as they are referenced but not provided in the code. - Compile using a C++ compiler: ```sh g++ -o ultrasonic_wave ultrasonic_wave.cpp ``` - Execute the compiled binary, passing necessary parameters and handling I/O streams as shown in the function definitions. ### Next Steps: To fully utilize this code, ensure that the missing function implementations are defined and handle all file stream operations properly. Additionally, validating the input parameters and considering edge cases will help ensure robust execution.
|
|
|
Post by nathanmyersc on Sept 18, 2024 19:13:13 GMT
Thank you for posting. Can you explain what it does and how to use or compile it? The Gist of it is that you assign all of the ascii symbols to be between -255 and 255 as i did in create lookup table. Then you assign each letter of your intention to its corresponding value in the lookup table and add the ultrasonic minimum. Which in the case of a 44100hz audio wav. I chose almost 22khz. So the amplitude for each letter corresponds to a frequency beyond normal human hearing. You can easily modify it to work with sine wave phasing and stuff ask chat gpt. So the amplitude data for each letter of your intention would fall somewhere in the 21khz or 22khz range. which is outside of norrmal hearing.
|
|
|
Post by AnthroHeart on Sept 18, 2024 19:22:43 GMT
Thank you for posting. Can you explain what it does and how to use or compile it? The Gist of it is that you assign all of the ascii symbols to be between -255 and 255 as i did in create lookup table. Then you assign each letter of your intention to its corresponding value in the lookup table and add the ultrasonic minimum. Which in the case of a 44100hz audio wav. I chose almost 22khz. So the amplitude for each letter corresponds to a frequency beyond normal human hearing. You can easily modify it to work with sine wave phasing and stuff ask chat gpt. So the amplitude data for each letter of your intention would fall somewhere in the 21khz or 22khz range. which is outside of norrmal hearing. C:\Repeater\C++>g++ -O3 -Wall Ultrasonic.cpp -o Ultrasonic.exe Ultrasonic.cpp:49:6: error: variable or field 'writeDataChunkNoWaveForm' declared void 49 | void writeDataChunkNoWaveForm(ofstream& wavFile, const uint32_t dataCyclesToWrite, const std::string& filteredText) | ^~~~~~~~~~~~~~~~~~~~~~~~ Ultrasonic.cpp:49:31: error: 'ofstream' was not declared in this scope 49 | void writeDataChunkNoWaveForm(ofstream& wavFile, const uint32_t dataCyclesToWrite, const std::string& filteredText) | ^~~~~~~~ Ultrasonic.cpp:49:41: error: 'wavFile' was not declared in this scope 49 | void writeDataChunkNoWaveForm(ofstream& wavFile, const uint32_t dataCyclesToWrite, const std::string& filteredText) | ^~~~~~~ Ultrasonic.cpp:49:50: error: expected primary-expression before 'const' 49 | void writeDataChunkNoWaveForm(ofstream& wavFile, const uint32_t dataCyclesToWrite, const std::string& filteredText) | ^~~~~ Ultrasonic.cpp:49:84: error: expected primary-expression before 'const' 49 | void writeDataChunkNoWaveForm(ofstream& wavFile, const uint32_t dataCyclesToWrite, const std::string& filteredText) You also forgot #include <unordered_map>
|
|
|
Post by AnthroHeart on Sept 18, 2024 19:37:21 GMT
Thank you for posting. Can you explain what it does and how to use or compile it? The Gist of it is that you assign all of the ascii symbols to be between -255 and 255 as i did in create lookup table. Then you assign each letter of your intention to its corresponding value in the lookup table and add the ultrasonic minimum. Which in the case of a 44100hz audio wav. I chose almost 22khz. So the amplitude for each letter corresponds to a frequency beyond normal human hearing. You can easily modify it to work with sine wave phasing and stuff ask chat gpt. So the amplitude data for each letter of your intention would fall somewhere in the 21khz or 22khz range. which is outside of norrmal hearing. I added the missing headers, and am still getting these errors:
C:\Repeater\C++>g++ -O3 -Wall -std=c++20 Ultrasonic.cpp -o Ultrasonic.exe Ultrasonic.cpp:9:61: error: 'uint32_t' does not name a type 9 | void writeDataChunkNoWaveForm(std::ofstream &wavFile, const uint32_t dataCyclesToWrite, const std::string &filteredText) { | ^~~~~~~~ Ultrasonic.cpp:6:1: note: 'uint32_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'? 5 | #include <vector> +++ |+#include <cstdint> 6 | #include <string> Ultrasonic.cpp:57:6: error: variable or field 'writeDataChunkNoWaveForm' declared void 57 | void writeDataChunkNoWaveForm(ofstream &wavFile, const uint32_t dataCyclesToWrite, const std::string &filteredText) | ^~~~~~~~~~~~~~~~~~~~~~~~ Ultrasonic.cpp:57:31: error: 'ofstream' was not declared in this scope; did you mean 'std::ofstream'? 57 | void writeDataChunkNoWaveForm(ofstream &wavFile, const uint32_t dataCyclesToWrite, const std::string &filteredText) | ^~~~~~~~ | std::ofstream In file included from C:/Strawberry/c/include/c++/13.2.0/ios:40, from C:/Strawberry/c/include/c++/13.2.0/istream:40, from C:/Strawberry/c/include/c++/13.2.0/fstream:40, from Ultrasonic.cpp:1: C:/Strawberry/c/include/c++/13.2.0/iosfwd:167:41: note: 'std::ofstream' declared here 167 | typedef basic_ofstream<char> ofstream; | ^~~~~~~~ Ultrasonic.cpp:57:41: error: 'wavFile' was not declared in this scope 57 | void writeDataChunkNoWaveForm(ofstream &wavFile, const uint32_t dataCyclesToWrite, const std::string &filteredText) | ^~~~~~~ Ultrasonic.cpp:57:50: error: expected primary-expression before 'const' 57 | void writeDataChunkNoWaveForm(ofstream &wavFile, const uint32_t dataCyclesToWrite, const std::string &filteredText) | ^~~~~ Ultrasonic.cpp:57:84: error: expected primary-expression before 'const' 57 | void writeDataChunkNoWaveForm(ofstream &wavFile, const uint32_t dataCyclesToWrite, const std::string &filteredText)
#include <fstream> // Add this line to fix the error #include <unordered_map> #include <iostream> // For std::cout #include <iomanip> // For std::setprecision #include <vector> #include <string>
// Your function using ofstream void writeDataChunkNoWaveForm(std::ofstream &wavFile, const uint32_t dataCyclesToWrite, const std::string &filteredText) { // Set frequency to be in the ultrasonic range (21 kHz
}
std::unordered_map<char, int> create_lookup_table_ultra(int maxamp, int minamp) {
// Create an empty unordered_map for the lookup table
std::unordered_map<char, int> lookup_table;
// Populate the lookup table with symbols and their corresponding amplitudes
for (int symbol = 0; symbol < 256; ++symbol) {
if (symbol % 2 == 0) {
// Map even ASCII values to the range [minamp, maxamp]
int adjusted_value = static_cast<int>((static_cast<double>(symbol) / 255) * (maxamp - minamp)) + minamp;
// Clamp adjusted_value to the range [minamp, maxamp]
adjusted_value = std::max(minamp, std::min(adjusted_value, maxamp));
lookup_table[static_cast<char>(symbol)] = adjusted_value; } else {
// Map odd ASCII values to the range [minamp, maxamp]
int adjusted_value = static_cast<int>((static_cast<double>(symbol) / 255) * (maxamp - minamp)) + minamp;
// Clamp adjusted_value to the range [minamp, maxamp]
adjusted_value = std::max(minamp, std::min(adjusted_value, maxamp));
lookup_table[static_cast<char>(symbol)] = adjusted_value; } }
return lookup_table; }
void writeDataChunkNoWaveForm(ofstream &wavFile, const uint32_t dataCyclesToWrite, const std::string &filteredText)
{
// Set frequency to be in the ultrasonic range (21 kHz)
double ultrasonicFrequency = 21922.0; // 21 kHz
// Ensure sampleRate is 44100 Hz (no need to adjust since it's suitable for ultrasonic frequencies up to 22.05 kHz)
if (sampleRate != 44100) {
sampleRate = 44100; }
const uint64_t dataChunkSizePos = writeDataChunkHeader(wavFile);
threadSafeCout("ENTERING DATA CHUNK WRITING FUNCTION\n");
// Create a vector to store the values for each ASCII character
std::unordered_map<char, int> values = create_lookup_table_ultra(255, -255);
const size_t bufferSize = 1024 * 1024 * numChannels * (bitsPerSample / 8); // Adjust buffer size as needed
std::vector<char> frames;
frames.reserve(bufferSize); // Reserve memory upfront
for (uint32_t i = 0; i < dataCyclesToWrite; ++i) {
// Generate ultrasonic waveform using the specified frequency
const int32_t value = (values[filteredText[i % filteredText.size()]] + ultrasonicFrequency) * volume_level;
// Insert samples into the frames vector
for (uint32_t j = 0; j < numChannels; ++j) {
insertSample(frames, 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);
threadSafeCout("EXITING DATA CHUNK WRITING FUNCTION\n"); }
|
|
|
Post by nathanmyersc on Sept 18, 2024 23:18:23 GMT
This is mostly compatible with your multi wave repeater source code if you inserted it in some fashion adding the appropiate includes.
#include <iostream> // for std::cout, std::fixed, std::setprecision
#include <fstream> // for std::ofstream
#include <vector> // for std::vector
#include <unordered_map> // for std::unordered_map
#include <cstdint> // for int32_t, uint32_t, uint64_t, etc.
#include <algorithm> // for std::max, std::min
#include <iomanip> // for std::setprecision, std::flush
#include <string> // for std::string
const uint32_t headerChunkSize = 0;
void insertSample(std::vector<char>& frames,const int32_t sample_value)
{
if (bitsPerSample == 32) {
int32_t sample_value_32bit = static_cast<int32_t>(sample_value);
frames.insert(frames.end(), reinterpret_cast<char*>(&sample_value_32bit), reinterpret_cast<char*>(&sample_value_32bit) + sizeof(sample_value_32bit));
} else {
int16_t sample_value_16bit = static_cast<int16_t>(sample_value);
frames.insert(frames.end(), reinterpret_cast<char*>(&sample_value_16bit), reinterpret_cast<char*>(&sample_value_16bit) + sizeof(sample_value_16bit));
}
}
uint32_t writeDataChunkHeader(ofstream& wavFile)
{
wavFile.write("data", 4); ///WRITING THE HEADER FOR THE DATA CHUNK OF THE WAV FILE
const uint64_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 uint64_t dataChunkSizePos,ofstream& wavFile)
{
uint32_t actualDataSize =(uint32_t(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);
}
std::unordered_map<char, int> create_lookup_table_ultra(int maxamp, int minamp) {
// Create an empty unordered_map for the lookup table
std::unordered_map<char, int> lookup_table;
// Populate the lookup table with symbols and their corresponding amplitudes
for (int symbol = 0; symbol < 256; ++symbol) {
if (symbol % 2 == 0) {
// Map even ASCII values to the range [minamp, maxamp]
int adjusted_value = static_cast<int>((static_cast<double>(symbol) / 255) * (maxamp - minamp)) + minamp;
// Clamp adjusted_value to the range [minamp, maxamp]
adjusted_value = std::max(minamp, std::min(adjusted_value, maxamp));
lookup_table[static_cast<char>(symbol)] = adjusted_value;
} else {
// Map odd ASCII values to the range [minamp, maxamp]
int adjusted_value = static_cast<int>((static_cast<double>(symbol) / 255) * (maxamp - minamp)) + minamp;
// Clamp adjusted_value to the range [minamp, maxamp]
adjusted_value = std::max(minamp, std::min(adjusted_value, maxamp));
lookup_table[static_cast<char>(symbol)] = adjusted_value;
}
}
return lookup_table;
}
//ENSURE THAT sampleRate numChannels bitsPerSample are defind as proper values likely 2 channels 16 bitsPerSample
void writeDataChunkNoWaveForm(ofstream& wavFile, const uint32_t dataCyclesToWrite, const std::string& filteredText)
{
// Set frequency to be in the ultrasonic range (21 kHz)
double ultrasonicFrequency = 21922.0; // 21 kHz
// Ensure sampleRate is 44100 Hz (no need to adjust since it's suitable for ultrasonic frequencies up to 22.05 kHz)
if (sampleRate != 44100) {
sampleRate = 44100;
}
const uint64_t dataChunkSizePos = writeDataChunkHeader(wavFile);
// Create a vector to store the values for each ASCII character
std::unordered_map<char, int> values = create_lookup_table_ultra(255, -255);
const size_t bufferSize = 1024 * 1024 * numChannels * (bitsPerSample / 8); // Adjust buffer size as needed
std::vector<char> frames;
frames.reserve(bufferSize); // Reserve memory upfront
for (uint32_t i = 0; i < dataCyclesToWrite; ++i) {
// Generate ultrasonic waveform using the specified frequency
const int32_t value = (values[filteredText[i%filteredText.size()]] + ultrasonicFrequency);
// Insert samples into the frames vector
for (uint32_t j = 0; j < numChannels; ++j) {
insertSample(frames, value);
}
if (frames.size() >= bufferSize || i == dataCyclesToWrite - 1) {
wavFile.write(frames.data(), frames.size());
frames.clear();
}
if (i % 100000 == 0 || i == dataCyclesToWrite - 1) {
std:::cout << "\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;
}
}
endDataChunk(dataChunkSizePos, wavFile);
}
|
|
|
Post by AnthroHeart on Sept 19, 2024 0:06:57 GMT
Your code is still giving all these errors:
C:\Repeater\C++>g++ -O3 -Wall -std=c++20 Ultrasonic.cpp -o Ultrasonic.exe Ultrasonic.cpp: In function 'void insertSample(std::vector<char>&, int32_t)': Ultrasonic.cpp:23:17: error: 'bitsPerSample' was not declared in this scope; did you mean 'insertSample'? 23 | if (bitsPerSample == 32) { | ^~~~~~~~~~~~~ | insertSample Ultrasonic.cpp: At global scope: Ultrasonic.cpp:39:31: error: 'ofstream' was not declared in this scope; did you mean 'std::ofstream'? 39 | uint32_t writeDataChunkHeader(ofstream& wavFile) | ^~~~~~~~ | std::ofstream In file included from C:/Strawberry/c/include/c++/13.2.0/ios:40, from C:/Strawberry/c/include/c++/13.2.0/ostream:40, from C:/Strawberry/c/include/c++/13.2.0/iostream:41, from Ultrasonic.cpp:1: C:/Strawberry/c/include/c++/13.2.0/iosfwd:167:41: note: 'std::ofstream' declared here 167 | typedef basic_ofstream<char> ofstream; | ^~~~~~~~ Ultrasonic.cpp:39:41: error: 'wavFile' was not declared in this scope 39 | uint32_t writeDataChunkHeader(ofstream& wavFile) | ^~~~~~~ Ultrasonic.cpp:53:51: error: 'ofstream' has not been declared 53 | void endDataChunk(const uint64_t dataChunkSizePos,ofstream& wavFile) | ^~~~~~~~ Ultrasonic.cpp: In function 'void endDataChunk(uint64_t, int&)': Ultrasonic.cpp:57:48: error: request for member 'tellp' in 'wavFile', which is of non-class type 'int' 57 | uint32_t actualDataSize =(uint32_t(wavFile.tellp()) - dataChunkSizePos ) - 4; /// CALCULATE DATA CHUNK SIZE | ^~~~~ Ultrasonic.cpp:63:17: error: request for member 'write' in 'wavFile', which is of non-class type 'int' 63 | wavFile.write(reinterpret_cast<const char*>(&paddingByte), sizeof(paddingByte)); | ^~~~~ Ultrasonic.cpp:71:13: error: request for member 'seekp' in 'wavFile', which is of non-class type 'int' 71 | wavFile.seekp(dataChunkSizePos,ios::beg); /// SEEK DATA CHUNK SIZE ELEMENT | ^~~~~ Ultrasonic.cpp:71:36: error: 'ios' has not been declared 71 | wavFile.seekp(dataChunkSizePos,ios::beg); /// SEEK DATA CHUNK SIZE ELEMENT | ^~~ Ultrasonic.cpp:73:13: error: request for member 'write' in 'wavFile', which is of non-class type 'int' 73 | wavFile.write(reinterpret_cast<const char*>(&actualDataSize),4); /// WRITE PROPER DATA CHUNK SIZE IN ELEMENTS POSITION | ^~~~~ Ultrasonic.cpp:75:13: error: request for member 'seekp' in 'wavFile', which is of non-class type 'int' 75 | wavFile.seekp(0,ios::end); | ^~~~~ Ultrasonic.cpp:75:21: error: 'ios' has not been declared 75 | wavFile.seekp(0,ios::end); | ^~~ Ultrasonic.cpp: At global scope: Ultrasonic.cpp:125:6: error: variable or field 'writeDataChunkNoWaveForm' declared void 125 | void writeDataChunkNoWaveForm(ofstream& wavFile, const uint32_t dataCyclesToWrite, const std::string& filteredText) | ^~~~~~~~~~~~~~~~~~~~~~~~ Ultrasonic.cpp:125:31: error: 'ofstream' was not declared in this scope; did you mean 'std::ofstream'? 125 | void writeDataChunkNoWaveForm(ofstream& wavFile, const uint32_t dataCyclesToWrite, const std::string& filteredText) | ^~~~~~~~ | std::ofstream C:/Strawberry/c/include/c++/13.2.0/iosfwd:167:41: note: 'std::ofstream' declared here 167 | typedef basic_ofstream<char> ofstream; | ^~~~~~~~ Ultrasonic.cpp:125:41: error: 'wavFile' was not declared in this scope 125 | void writeDataChunkNoWaveForm(ofstream& wavFile, const uint32_t dataCyclesToWrite, const std::string& filteredText) | ^~~~~~~ Ultrasonic.cpp:125:50: error: expected primary-expression before 'const' 125 | void writeDataChunkNoWaveForm(ofstream& wavFile, const uint32_t dataCyclesToWrite, const std::string& filteredText) | ^~~~~ Ultrasonic.cpp:125:84: error: expected primary-expression before 'const' 125 | void writeDataChunkNoWaveForm(ofstream& wavFile, const uint32_t dataCyclesToWrite, const std::string& filteredText)
|
|
|
Post by nathanmyersc on Sept 19, 2024 4:35:22 GMT
Yeaah its not a complete program. its meant to be inserted in your multiwave program. Here i just made a complete program for you to fool around with Attachments:main.cpp (26.13 KB)
|
|
|
Post by AnthroHeart on Sept 19, 2024 5:44:11 GMT
Yeaah its not a complete program. its meant to be inserted in your multiwave program. Here i just made a complete program for you to fool around with Thank you. I got it working.
It's producing the below peaks when I choose volume 600.
The peaks are around -40dB. Should they be closer to 0dB or max volume if 600 was chosen?
Frequency (Hz) Loudness (dB) 1574.95 -40.37 3149.9 -40.23 4724.86 -44.98 6300.14 -37.95 7875.1 -40.07 9450.05 -49.24 11025 -44.7 12599.95 -45.58 14174.9 -37.76 15749.86 -50.19 17325.14 -40.49 18900.1 -42.04 20475.05 -56.13
|
|
|
Post by nathanmyersc on Sept 19, 2024 7:32:31 GMT
Yeaah its not a complete program. its meant to be inserted in your multiwave program. Here i just made a complete program for you to fool around with Thank you. I got it working.
It's producing the below peaks when I choose volume 600.
The peaks are around -40dB. Should they be closer to 0dB or max volume if 600 was chosen?
Frequency (Hz) Loudness (dB) 1574.95 -40.37 3149.9 -40.23 4724.86 -44.98 6300.14 -37.95 7875.1 -40.07 9450.05 -49.24 11025 -44.7 12599.95 -45.58 14174.9 -37.76 15749.86 -50.19 17325.14 -40.49 18900.1 -42.04 20475.05 -56.13 I actually should have removed the ability to select a volume. I think that it would signifigantly alter the frequency. try 99 or 100.
I rearranged a few things and removed the ability to select a volume as it messes up the premise of ultrasound. And added file size to the console while you choose the repetitions Attachments:main.cpp (29.18 KB)
|
|
|
Post by AnthroHeart on Sept 19, 2024 11:12:27 GMT
Thank you. I got it working.
It's producing the below peaks when I choose volume 600.
The peaks are around -40dB. Should they be closer to 0dB or max volume if 600 was chosen?
I would check your output WAV in Audacity and zoom in to make sure.
Frequency (Hz) Loudness (dB) 1574.95 -40.37 3149.9 -40.23 4724.86 -44.98 6300.14 -37.95 7875.1 -40.07 9450.05 -49.24 11025 -44.7 12599.95 -45.58 14174.9 -37.76 15749.86 -50.19 17325.14 -40.49 18900.1 -42.04 20475.05 -56.13 I actually should have removed the ability to select a volume. I think that it would signifigantly alter the frequency. try 99 or 100.
I rearranged a few things and removed the ability to select a volume as it messes up the premise of ultrasound. And added file size to the console while you choose the repetitions
I zoomed in on the WAV and all the samples are the same value. It doesn't change between samples.
Also the output filename is strange: File '0.000000Hz_SmoothingPercent_-100.000000_44100.wav' deleted successfully.
|
|
|
Post by AnthroHeart on Sept 19, 2024 17:27:17 GMT
Thank you. I got it working.
It's producing the below peaks when I choose volume 600.
The peaks are around -40dB. Should they be closer to 0dB or max volume if 600 was chosen?
Frequency (Hz) Loudness (dB) 1574.95 -40.37 3149.9 -40.23 4724.86 -44.98 6300.14 -37.95 7875.1 -40.07 9450.05 -49.24 11025 -44.7 12599.95 -45.58 14174.9 -37.76 15749.86 -50.19 17325.14 -40.49 18900.1 -42.04 20475.05 -56.13 I actually should have removed the ability to select a volume. I think that it would signifigantly alter the frequency. try 99 or 100.
I rearranged a few things and removed the ability to select a volume as it messes up the premise of ultrasound. And added file size to the console while you choose the repetitions
I asked GPT o1-mini to write it from scratch and it made code that compiled with no warnings. This seems to work:
|
|
|
Post by AnthroHeart on Sept 19, 2024 17:56:39 GMT
This one lets you select your frequency. So you can put Ultrasonic frequencies if you want. Though I still hear them.
You pick a base frequency. At lower frequencies (i.e. 528Hz) it sounds more like a pure tone, with encoding. At higher frequencies like ultrasonic, there is more "noise" it seems. You can even do 7.83Hz low frequency.
This code is clean with no errors or warnings, even using -Wall.
nathanmyersc It's about 9kB smaller than your code. So it may be a good place to start from.
|
|
|
Post by AnthroHeart on Sept 19, 2024 19:14:39 GMT
I like using the 5th Octave of the Schumann Resonance: 250.56 Hz.
|
|