Changeset 6059ec7 in ammosreader for sample_scripts


Ignore:
Timestamp:
06/28/22 19:22:31 (3 years ago)
Author:
Enrico Schwass <ennoausberlin@…>
Branches:
AmmosSource, guix
Children:
b41e975
Parents:
72b50cd
Message:

accessors added - AmmosAudioDataBlock added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sample_scripts/audio_reader.py

    r72b50cd r6059ec7  
    11import sys
    22import os
     3import io
     4from pydub import AudioSegment
     5from pydub.playback import play
     6
    37sys.path.append('../src/')
    48
     
    1721
    1822    dat_file.read_all_frames_left()
    19     print(dat_file.container.size())
     23    print("Sample rate:", dat_file.container.global_frames[0].global_frame_body.data_header.sample_rate)
     24    print("Container size:", dat_file.container.size())
     25    pcm_data = dat_file.pcm_for_channel(0)
     26    print("PCM data size total:", len(pcm_data))
     27    data = AudioSegment.from_raw(io.BytesIO(pcm_data),
     28                                 sample_width=2,
     29                                 frame_rate=22050,
     30                                 channels=1)
     31    play(data)
Note: See TracChangeset for help on using the changeset viewer.