WAV files are a great format to use when working with large audio files. They preserve the quality of the audio, and as long as you don’t have any worries about storage size or web-sharing, they can be ideal for audio and music software projects. So, if you have a large MP3 file you want to convert into the WAV format, the following API can be run in C/C++ to automate the otherwise time-consuming task for you.
To begin, we will need to install libcurl to the C/C++ project:
Moving on, we are ready to call the conversion function; the only required parameter is your input file, but you have the option to add the file URL (recommended for files over 2 GB) or specify the desired sample rate in khZ (default is to allow the API to choose the rate automatically).
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "https://api.cloudmersive.com/video/convert/to/wav");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "fileUrl: <string>");
headers = curl_slist_append(headers, "sampleRate: <number>");
headers = curl_slist_append(headers, "Content-Type: multipart/form-data");
headers = curl_slist_append(headers, "Apikey: YOUR-API-KEY-HERE");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
mime = curl_mime_init(curl);
part = curl_mime_addpart(mime);
curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
res = curl_easy_perform(curl);
The processing time may be longer or shorter based on the size of your file, but the wait time (and stress!) is significantly less than what it would take if you attempted the process manually.