Sound/wav_files in replicators

Yoon Bai's Avatar

Yoon Bai

14 May, 2021 01:39 PM

Hi Chris,

I was wondering if I could get your help with playing audio (WAV) files on MWorks. I would like to put a long list of WAV file in a list/range replicator, but noticed the following compilation error:

Component 'sound/wav_file' is not allowed inside component 'range_replicator' [line 384, column 9]

 - And here are two code snippets I’ve tried so far:

// snippet 1: audio only
    range_replicator (
        variable = filename
        from = 0
        to = num_original_videos - 1
        step = 1
        ) {
        wav_file ${filename} (
            path = 'filenames(audio/audio_*.wav)'
            )
    }

    // snippet 2: audio only
    list_replicator (
        variable = filename
        values = 'filenames(audio/audio_*.wav)'
        ) {
        wav_file ${filename} (
            path = ${filename}
            autoplay = true
            volume = 0
            )
    }

  - I’m not sure if I’m not using the right syntax, or if sound/wav_file is not supported as an indexable stimulus group. Do you have any suggestions?

Thanks!
Yoon

  1. Support Staff 1 Posted by Christopher Sta... on 14 May, 2021 02:14 PM

    Christopher Stawarz's Avatar

    Hi Yoon,

    Like the error message says, sounds aren't allowed inside replicators. Looking at the MWorks source code, it's not immediately clear to me why they aren't allowed. Let me see if I can figure it out and change things so they are allowed.

    In the meantime, I think you're stuck doing things the hard way and defining each sound individually. Sorry!

    Chris

  2. 2 Posted by Yoon Bai on 25 May, 2021 06:50 PM

    Yoon Bai's Avatar

    Hi Chris,

    I wanted to follow up with a workaround, hoping it might help others in the meantime. The workaround is to convert sound clips to video clips. I converted WAV files to MP4 files using ffmpeg <https://ffmpeg.org/> (and added a still image throughout the duration of the sound clip) and this worked well with replicators (verified this on MWorks 0.9 and 0.10).

    Best,
    Yoon

  3. Support Staff 3 Posted by Christopher Sta... on 26 May, 2021 08:15 PM

    Christopher Stawarz's Avatar

    Hi Yoon,

    That's a clever workaround. Thanks for sharing!

    Chris

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac