I'm trying to do some project at C because I'm new at coding,
I making a Decoder and Encoder for Morse code.
I use morse configuration by user free choice of: frequency[Hz] of dot, frequency[Hz] of dash, time of dot[ms], time of dash[ms], and delay between dot and dash[ms].
the user writing the configuration and the text, the text converted to morse code.
now I want to make an output WAV file of the morse code text (dot and dash) with the user configuration (part of the WAV file).
I tried a lot of examples from the internet and GitHub and I didn't succeed...
this part of my code:
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include "config.h" #include <conio.h> int transmit() { //---------------------------------Setting & Variables-----------------------------------------// system("cls");//clear screen //char T[25] = { '\0' }; //transmit user input variable char str[25],str1[100]; //str contain the text from user, str1 contain the morse convert int i = 0, j = 0; int count = 0; //unsigned int frequancy_dash, frequancy_dot, dash_time, dot_time, delay_dd; //int index = 0,c; //char buffer[256]; //to read from config.txt struct Config config; //create stuck type Config named config int configmain(void); //-------------------------------Read Configuration file---------------------------------------// FILE* fp; fp = fopen("config.txt", "r"); if (fp == NULL) //check if the file exist if not --> go to config function to create new config.txt file { config(); } else //if config.txt empty --> go to config function to create new config.txt file { fseek(fp, 0, SEEK_END);//start from 0 location to the end of the file if (ftell(fp) == 0) //check if the file empty { config(); } } rewind(fp);//back to file start while (fgets(buffer, sizeof(buffer), fp)) //read all config.txt { puts(buffer); } rewind(fp);//back to file start while (fgets(buffer, sizeof(buffer), fp)) { if (!parse(buffer)) { fclose(fp); return 0; } } gets(enter);//recive the 'Enter' pressing from user fclose(fp); */ //new config v1.2// //-------------------------------Read Configuration file---------------------------------------// FILE* fp; fp = fopen("config.txt", "r"); if (fp == NULL) //check if the file exist if not --> go to config function to create new config.txt file { printf("error reading config.txt - Press Enter\n"); //UI error message system("cls"); //clear screen configmain(); return 1; } system("cls"); //clear screen //--------------------------------Display configuration----------------------------------------// config_read(&config, "config.txt"); //read config.txt file printf("Exists configuration:\n"); //UI message printf("Freq dot is %i\n", config.freq_dot); // UI Display what is in config file printf("Freq dash is %i\n", config.freq_dash); printf("Time dot is %i\n", config.time_dot); printf("Time dash is %i\n", config.time_dash); printf("Delay %i\n", config.delay); //-----------------------------------Recive user text------------------------------------------// int morse(); //define morse function morse(str,str1); //convert string to morse //WAV_morse_create(str1) // <-------------------[[[here i don't know what to do... i dont have this function its only for example ]]]
ill glad for your help.