Skip to content

Instantly share code, notes, and snippets.

@matteing
Created November 23, 2019 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matteing/479bc868693e297de296cd3d24449a9d to your computer and use it in GitHub Desktop.
Save matteing/479bc868693e297de296cd3d24449a9d to your computer and use it in GitHub Desktop.
/*
Nombre: Sergio Mattei, Jasiel Rivera
ID: 801183252, 801-18-6809
Class/Seccion: CCOM 3033 SEC 001
Nombre de archivo: main_soundp_jasiel_mattei.cpp
Descripción: This thing modifies .wav files.
*/
#include "audiomanip.h"
/// \file
/// \fn void RemoveVocals(AudioBuffer frames[], int N)
/// \~English
/// \brief Given the audio frames of the sound clip, remove
/// the vocals from the clip.
/// \param frames array that contains audio samples, it will be modified
/// this function.
/// \param N number of audio samples (per channel)
/// \~Spanish
/// \brief Dadas las tramas de audio de un clip de sonido, remueve
/// las vocales del clip
/// \param arreglo de tramas que contiene las muestras, será modificado en
/// esta funcion.
/// \param N numero de muestras de audio (por canal)
void RemoveVocals(AudioBuffer frames[], int N)
{
for (int i = 0; i < N; i++) {
frames[i].right = frames[i].left = (frames[i].left - frames[i].right) / 2;
}
}
/// \fn void AudioFadeIn(AudioBuffer frames[], int N, int fade_length)
/// \~English
/// \brief Perform an audio fade in of the sound clip
/// \param frames array that contains audio samples, it will modified
/// this function.
/// \param N number of audio samples (per channel)
/// \param fade_length length of the fade in, in terms of audio samples
/// \~Spanish
/// \brief Performa un desbanecimiento de audio de un clip de sonido
/// \param arreglo de tramas que contiene las muestras, será modificado en
/// esta funcion.
/// \param N numero de muestras de audio (por canal)
/// \param fade_length largo del desbanecimiento, en terminos de muestras de
/// audio.
///
void AudioFadeIn(AudioBuffer frames[], int N, int fade_length)
{
for (int i = 0; i < fade_length; i++) {
frames[i].left *= i / static_cast<float>(fade_length);
frames[i].right *= i / static_cast<float>(fade_length);
}
}
/// \fn void AudioFadeOut(AudioBuffer frames[], int N, int fade_length)
/// \~English
/// \brief Perform an audio fade out of the sound clip
/// \param frames array that contains audio samples, it will modified
/// this function.
/// \param N number of audio samples (per channel)
/// \param fade_length length of the fade out, in terms of audio samples
///
/// \~Spanish
/// \brief Performa un incremento del sonido de audio de un clip de sonido
/// \param arreglo de tramas que contiene las muestras, será modificado en
/// esta funcion.
/// \param N numero de muestras de audio (por canal)
/// \param fade_length largo del incremento del sonido, en terminos de muestras de
/// audio.
///
void AudioFadeOut(AudioBuffer frames[], int N, int fade_length)
{
for (int x = N - 1, y = 0; x > (N - fade_length); x--, y++) {
frames[x].left *= y / static_cast<float>(fade_length);
frames[x].right *= y / static_cast<float>(fade_length);
}
}
/// \fn void LeftToRight(AudioBuffer frames[], int N, int pan_length)
/// \~English
/// \brief Performs a panning effect from left to right
/// \param frames array that contains audio samples, it will modified
/// this function.
/// \param N number of audio samples (per channel)
/// \param pan_length length of the panning effect, in terms of audio samples
///
/// \~Spanish
/// \brief Performa un efecto panoramico del audio de un clip de sonido
/// \param arreglo de tramas que contiene las muestras, será modificado en
/// esta funcion.
/// \param N numero de muestras de audio (por canal)
/// \param pan_length largo del efecto panoramico, en terminos de muestras de
/// audio.
void LeftToRight(AudioBuffer frames[], int N, int pan_length)
{
for(int x = 0, y = pan_length; x < N; x++, y--) {
frames[x].left *= y / static_cast<float>(pan_length);
frames[x].right *= x / static_cast<float>(pan_length);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment