Exemplo n.º 1
0
def mix_channels(settings, p=None):
    """ Mix channels of the settings.
    
    :param settings: a list of dictionaries with extracted information from a settings file.
    :param p is a progress dialog

    """
    # variables for displaying
    total = len(settings)

    mixer_left = sppasChannelMixer()
    mixer_right = sppasChannelMixer()

    for i, channel in enumerate(settings):
        if p:
            p.update(float(i)/total, "Formatting channel " + str(i+1) + " of " + str(total))

        coeff_left = 50.
        coeff_right = 50.
        if channel['panoramic'] < 0:
            coeff_left = float(100 - channel['panoramic'])/2
            coeff_right = float(100 - coeff_left) - channel['factor'] * channel['panoramic']
        elif channel['panoramic'] > 0:
            coeff_right = float(100 + channel['panoramic'])/2
            coeff_left = float(100 - coeff_right) + channel['factor'] * channel['panoramic']

        mixer_left.append_channel(channel['channel'], coeff_left/100. * (channel['volume'])/100.)
        mixer_right.append_channel(channel['channel'], coeff_right/100. * (channel['volume'])/100.)

    return mixer_left, mixer_right
Exemplo n.º 2
0
def mix_channels(settings, p=None):
    """ Mix channels of the settings.
    
    :param settings: a list of dictionaries with extracted information from a settings file.
    :param p is a progress dialog

    """
    # variables for displaying
    total = len(settings)

    mixer_left = sppasChannelMixer()
    mixer_right = sppasChannelMixer()

    for i, channel in enumerate(settings):
        if p:
            p.update(
                float(i) / total,
                "Formatting channel " + str(i + 1) + " of " + str(total))

        coeff_left = 50.
        coeff_right = 50.
        if channel['panoramic'] < 0:
            coeff_left = float(100 - channel['panoramic']) / 2
            coeff_right = float(
                100 - coeff_left) - channel['factor'] * channel['panoramic']
        elif channel['panoramic'] > 0:
            coeff_right = float(100 + channel['panoramic']) / 2
            coeff_left = float(
                100 - coeff_right) + channel['factor'] * channel['panoramic']

        mixer_left.append_channel(
            channel['channel'], coeff_left / 100. * (channel['volume']) / 100.)
        mixer_right.append_channel(
            channel['channel'],
            coeff_right / 100. * (channel['volume']) / 100.)

    return mixer_left, mixer_right
Exemplo n.º 3
0
def normalize_channels(settings, p=None):
    """ Normalize the length of channels of the settings.

    :param settings: a list of dictionaries with extracted information from a settings file.
    :param p: a progress dialog

    """
    norm = sppasChannelMixer()

    if p:
        p.update(0.25, "Load channels to normalize. ")
    for channel in settings:
        norm.append_channel(channel['channel'])

    if p:
        p.update(0.50, "Normalize length of each channel... ")
    norm.norm_length()

    if p:
        p.update(0.90, "Save normalized channels. ")
    for i, channel in enumerate(settings):
        channel['channel'] = norm.get_channel(i)
Exemplo n.º 4
0
def normalize_channels(settings, p=None):
    """ Normalize the length of channels of the settings.

    :param settings: a list of dictionaries with extracted information from a settings file.
    :param p: a progress dialog

    """
    norm = sppasChannelMixer()

    if p:
        p.update(0.25, "Load channels to normalize. ")
    for channel in settings:
        norm.append_channel(channel['channel'])

    if p:
        p.update(0.50, "Normalize length of each channel... ")
    norm.norm_length()

    if p:
        p.update(0.90, "Save normalized channels. ")
    for i, channel in enumerate(settings):
        channel['channel'] = norm.get_channel(i)
Exemplo n.º 5
0
import sppas.src.audiodata.aio
from sppas.src.audiodata.channelsmixer import sppasChannelMixer

# ----------------------------------------------------------------------------

parser = ArgumentParser(usage="%s -w input files" % os.path.basename(PROGRAM),
                        description="... a script to get the minimum and maximum values"
                                    " of a mix between mono audio files.")

parser.add_argument("-w",
                    metavar="file",
                    nargs='+',
                    required=True,
                    help='Audio Input file names')

if len(sys.argv) <= 1:
    sys.argv.append('-h')

args = parser.parse_args()

# ----------------------------------------------------------------------------

mixer = sppasChannelMixer()

for inputFile in args.w:
    audio = sppas.src.audiodata.aio.open(inputFile)
    idx = audio.extract_channel(0)
    mixer.append_channel(audio.get_channel(idx))

print(mixer.get_minmax())
Exemplo n.º 6
0
from sppas.src.audiodata.channelsmixer import sppasChannelMixer

# ----------------------------------------------------------------------------

parser = ArgumentParser(
    usage="%s -w input files" % os.path.basename(PROGRAM),
    description="... a script to get the minimum and maximum values"
    " of a mix between mono audio files.")

parser.add_argument("-w",
                    metavar="file",
                    nargs='+',
                    required=True,
                    help='Audio Input file names')

if len(sys.argv) <= 1:
    sys.argv.append('-h')

args = parser.parse_args()

# ----------------------------------------------------------------------------

mixer = sppasChannelMixer()

for inputFile in args.w:
    audio = sppas.src.audiodata.aio.open(inputFile)
    idx = audio.extract_channel(0)
    mixer.append_channel(audio.get_channel(idx))

print(mixer.get_minmax())