Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
musicinformationretrieval-com
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
A.S.
musicinformationretrieval-com
Commits
ae1f140c
Commit
ae1f140c
authored
Jun 28, 2018
by
Steve Tjoa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
real time audio spectrogram in the terminal
parent
f32f10d9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
realtimeaudio.py
realtimeaudio.py
+44
-0
No files found.
realtimeaudio.py
0 → 100644
View file @
ae1f140c
"""
PyAudio Example: Make a wire between input and output (i.e., record a
few samples and play them back immediately).
This is the callback (non-blocking) version.
"""
import
numpy
import
pyaudio
import
time
WIDTH
=
2
CHANNELS
=
1
RATE
=
44100
p
=
pyaudio
.
PyAudio
()
def
g
(
z
):
if
z
:
return
'*'
else
:
return
' '
def
callback
(
in_data
,
frame_count
,
time_info
,
status
):
audio_data
=
numpy
.
fromstring
(
in_data
,
dtype
=
numpy
.
float32
)
X
=
numpy
.
log
(
abs
(
numpy
.
fft
.
fft
(
audio_data
)))
print
(
''
.
join
(
g
(
z
>
1.5
)
for
z
in
X
[:
140
])
)
return
(
in_data
,
pyaudio
.
paContinue
)
stream
=
p
.
open
(
format
=
pyaudio
.
paFloat32
,
channels
=
CHANNELS
,
rate
=
RATE
,
input
=
True
,
output
=
True
,
stream_callback
=
callback
)
stream
.
start_stream
()
while
stream
.
is_active
():
time
.
sleep
(
0.2
)
stream
.
stop_stream
()
stream
.
close
()
p
.
terminate
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment