add audio function to copy L signal to R channel

Implements #4075.
This commit is contained in:
Alexandros Theodotou 2023-12-24 15:35:47 +09:00
parent 923a984467
commit ca90d3bc48
No known key found for this signature in database
GPG Key ID: 022EAE42313D70F3
2 changed files with 24 additions and 31 deletions

View File

@ -12,7 +12,7 @@
#ifndef __AUDIO_AUDIO_FUNCTION_H__
#define __AUDIO_AUDIO_FUNCTION_H__
#include "utils/yaml.h"
#include <stdbool.h>
#include <glib/gi18n.h>
@ -37,6 +37,7 @@ typedef enum AudioFunctionType
AUDIO_FUNCTION_NUDGE_RIGHT,
AUDIO_FUNCTION_REVERSE,
AUDIO_FUNCTION_PITCH_SHIFT,
AUDIO_FUNCTION_COPY_L_TO_R,
/** External program. */
AUDIO_FUNCTION_EXT_PROGRAM,
@ -51,21 +52,12 @@ typedef enum AudioFunctionType
AUDIO_FUNCTION_INVALID,
} AudioFunctionType;
static const cyaml_strval_t audio_function_type_strings[] = {
{N_ ("Invert"), AUDIO_FUNCTION_INVERT },
{ N_ ("Normalize peak"), AUDIO_FUNCTION_NORMALIZE_PEAK },
{ N_ ("Normalize RMS"), AUDIO_FUNCTION_NORMALIZE_RMS },
{ N_ ("Normalize LUFS"), AUDIO_FUNCTION_NORMALIZE_LUFS },
{ N_ ("Linear fade in"), AUDIO_FUNCTION_LINEAR_FADE_IN },
{ N_ ("Linear fade out"), AUDIO_FUNCTION_LINEAR_FADE_OUT},
{ N_ ("Nudge left"), AUDIO_FUNCTION_NUDGE_LEFT },
{ N_ ("Nudge right"), AUDIO_FUNCTION_NUDGE_RIGHT },
{ N_ ("Reverse"), AUDIO_FUNCTION_REVERSE },
{ N_ ("Pitch shift"), AUDIO_FUNCTION_PITCH_SHIFT },
{ N_ ("External program"), AUDIO_FUNCTION_EXT_PROGRAM },
{ N_ ("Guile script"), AUDIO_FUNCTION_GUILE_SCRIPT },
{ N_ ("Custom plugin"), AUDIO_FUNCTION_CUSTOM_PLUGIN },
{ N_ ("Invalid"), AUDIO_FUNCTION_INVALID },
static const char * audio_function_type_strings[] = {
N_ ("Invert"), N_ ("Normalize peak"), N_ ("Normalize RMS"),
N_ ("Normalize LUFS"), N_ ("Linear fade in"), N_ ("Linear fade out"),
N_ ("Nudge left"), N_ ("Nudge right"), N_ ("Reverse"),
N_ ("Pitch shift"), N_ ("Copy L to R"), N_ ("External program"),
N_ ("Guile script"), N_ ("Custom plugin"), N_ ("Invalid"),
};
typedef struct AudioFunctionOpts
@ -80,7 +72,7 @@ typedef struct AudioFunctionOpts
static inline const char *
audio_function_type_to_string (AudioFunctionType type)
{
return audio_function_type_strings[type].str;
return audio_function_type_strings[type];
}
char *

View File

@ -305,20 +305,6 @@ apply_plugin (
return 0;
}
/**
* Applies the given action to the given selections.
*
* This will save a file in the pool and store the pool ID in
* the selections.
*
* @param sel Selections to edit.
* @param type Function type. If invalid is passed, this will
* simply add the audio file in the pool for the unchanged
* audio material (used in audio selection actions for the
* selections before the change).
*
* @return Whether successful.
*/
bool
audio_function_apply (
ArrangerSelections * sel,
@ -553,6 +539,21 @@ audio_function_apply (
}
}
break;
case AUDIO_FUNCTION_COPY_L_TO_R:
use_interleaved = false;
if (channels == 2)
{
dsp_copy (ch_dest_frames[1], ch_src_frames[0], num_frames);
}
else
{
g_set_error_literal (
error, Z_AUDIO_AUDIO_FUNCTION_ERROR,
Z_AUDIO_AUDIO_FUNCTION_ERROR_FAILED,
_ ("This function can only be used on audio clips with 2 channels"));
return false;
}
break;
case AUDIO_FUNCTION_EXT_PROGRAM:
{
AudioClip * tmp_clip = audio_clip_new_from_float_array (