Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while running sample script #1

Open
mawic opened this issue Apr 23, 2020 · 4 comments
Open

Error while running sample script #1

mawic opened this issue Apr 23, 2020 · 4 comments

Comments

@mawic
Copy link

mawic commented Apr 23, 2020

Hi,
I wanted to run the sample. But I get the following error:
Traceback (most recent call last): File "ptttl/ptttl_audio_encoder.py", line 87, in <module> ptttl_to_mp3(ptttl_data, sys.argv[2], 0.5, tones.SINE_WAVE) File "ptttl/ptttl_audio_encoder.py", line 71, in ptttl_to_mp3 ptttl_to_wav(ptttl_data, wavfile, amplitude, wavetype) File "ptttl/ptttl_audio_encoder.py", line 67, in ptttl_to_wav samples = _generate_wav_file(data, amplitude, wavetype, wav_filename) File "ptttl/ptttl_audio_encoder.py", line 57, in _generate_wav_file Mixer(SAMPLE_RATE, amplitude).mix(filename, samples) TypeError: mix() takes 1 positional argument but 3 were given

Then I tried to fix it by myself. I had the idea to replace this line:
Mixer(SAMPLE_RATE, amplitude).mix(filename, samples)
by
Mixer(SAMPLE_RATE, amplitude).write_wav(filename, samples)

But it also doesn't work. Any idea how to fix it? It tested the code on Windows 10 and Linux.
Thanks!

@eriknyquist
Copy link
Owner

eriknyquist commented Apr 23, 2020 via email

@eriknyquist
Copy link
Owner

eriknyquist commented Apr 24, 2020 via email

@mawic
Copy link
Author

mawic commented Apr 28, 2020

Hi Erik,
thanks for the quick fix. I got it running. However, it fixed some lines of code in tones. I assume you forgot to push 1.0.1.
This are my new code in mixer.py

        """
        Mixes all tracks into a single stream of samples and writes to a
        .wav audio file

        :param str filename: name of file to write
        """

        f = wave.open(filename, 'w')

        if sampledata is None:
            sampledata = self.mix().serialize()

        f.setparams((tones.NUM_CHANNELS, tones.DATA_SIZE, self._rate,
            int(len(sampledata) / 2), "NONE", "Uncompressed"))

        f.writeframes(sampledata)
        f.close()```

@eriknyquist
Copy link
Owner

eriknyquist commented Apr 28, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants