mirror of
https://github.com/clockworkpi/launcher.git
synced 2025-12-16 19:58:51 +01:00
Merge pull request #59 from cuu/master
modification in the music spectrum
This commit is contained in:
commit
c25c74a0bc
File diff suppressed because it is too large
Load Diff
@ -34,21 +34,27 @@ class PIFI(object):
|
|||||||
_FIRST_SELECTED_BIN = 5
|
_FIRST_SELECTED_BIN = 5
|
||||||
_NUMBER_OF_SELECTED_BINS = 1024
|
_NUMBER_OF_SELECTED_BINS = 1024
|
||||||
|
|
||||||
|
_samples_buffer = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.sampleSize = self._SAMPLE_SIZE
|
self.sampleSize = self._SAMPLE_SIZE
|
||||||
self.samplingRate = self._SAMPLING_RATE
|
self.samplingRate = self._SAMPLING_RATE
|
||||||
|
|
||||||
def GetSpectrum(self,fifoFile,trim_by=10,log_scale=False,div_by=100):
|
def GetSpectrum(self,fifoFile,trim_by=4,log_scale=False,div_by=100):
|
||||||
try:
|
try:
|
||||||
rawSamples = os.read(fifoFile,self.sampleSize) # will return empty lines (non-blocking)
|
rawSamples = os.read(fifoFile,self.sampleSize) # will return empty lines (non-blocking)
|
||||||
if len(rawSamples) < 1:
|
if len(rawSamples) < 1:
|
||||||
# print("Read error")
|
# print("Read error")
|
||||||
return rawSamples
|
pass
|
||||||
|
else:
|
||||||
|
self._samples_buffer = rawSamples
|
||||||
except Exception,e:
|
except Exception,e:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if self._samples_buffer == None:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
data = numpy.fromstring(rawSamples, dtype=numpy.int16)
|
data = numpy.fromstring(self._samples_buffer, dtype=numpy.int16)
|
||||||
|
|
||||||
data = data * numpy.hanning(len(data))
|
data = data * numpy.hanning(len(data))
|
||||||
|
|
||||||
@ -201,7 +207,7 @@ class MPDSpectrumPage(Page):
|
|||||||
#print("sleeping... 0.01")
|
#print("sleeping... 0.01")
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
self.read_retry+=1
|
self.read_retry+=1
|
||||||
if self.read_retry > 40:
|
if self.read_retry > 20:
|
||||||
os.close(self._FIFO)
|
os.close(self._FIFO)
|
||||||
self._FIFO = os.open(self._PIFI._MPD_FIFO, os.O_RDONLY | os.O_NONBLOCK)
|
self._FIFO = os.open(self._PIFI._MPD_FIFO, os.O_RDONLY | os.O_NONBLOCK)
|
||||||
self.read_retry = 0
|
self.read_retry = 0
|
||||||
@ -354,8 +360,9 @@ class MPDSpectrumPage(Page):
|
|||||||
if len(spects) == 0:
|
if len(spects) == 0:
|
||||||
return
|
return
|
||||||
# print("spects:",spects)
|
# print("spects:",spects)
|
||||||
step = int( round( len( spects ) / meterNum) )
|
|
||||||
|
|
||||||
|
step = int( round( len( spects ) / meterNum) )
|
||||||
|
# print(len(spects))
|
||||||
self._bbs = []
|
self._bbs = []
|
||||||
|
|
||||||
for i in range(0,meterNum):
|
for i in range(0,meterNum):
|
||||||
|
|||||||
@ -422,7 +422,7 @@ def socket_thread(main_screen):
|
|||||||
if callable( current_page_key_down_cb ):
|
if callable( current_page_key_down_cb ):
|
||||||
main_screen._CurrentPage.KeyDown(escevent)
|
main_screen._CurrentPage.KeyDown(escevent)
|
||||||
|
|
||||||
if tokens[0].lower() == "quit":
|
if tokens[0].lower() == "quit": #eg: echo "quit" | socat - UNIX-CONNECT:/tmp/gameshell
|
||||||
conn.close()
|
conn.close()
|
||||||
on_exit_cb = getattr(main_screen,"OnExitCb",None)
|
on_exit_cb = getattr(main_screen,"OnExitCb",None)
|
||||||
if on_exit_cb != None:
|
if on_exit_cb != None:
|
||||||
@ -488,7 +488,7 @@ def big_loop():
|
|||||||
gobject.timeout_add(3000,title_bar.GObjectRoundRobin)
|
gobject.timeout_add(3000,title_bar.GObjectRoundRobin)
|
||||||
|
|
||||||
|
|
||||||
# socket_thread(main_screen)
|
socket_thread(main_screen)
|
||||||
|
|
||||||
gobject_loop()
|
gobject_loop()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user