Adding the new tree for 0.1

parent dc2c0e65
[Desktop Entry]
Version=1.0
Name=LibreFDATool
Comment=Libre Filter Design and Analysis Tool
Type=Application
Exec=/usr/bin/librefdatool
Icon=/usr/share/librefdatool/data/icons/logo.png
Terminal=false
[Desktop Entry]
Version=1.0
Name=LibreFDATool
Comment=Libre Filter Design and Analysis Tool
Type=Application
Exec=/usr/bin/librefdatool
Icon=/usr/share/librefdatool/data/icons/librefdatool.svg
Terminal=false
Gespeaker is a GTK+ frontend for eSpeak and mbrola.
Copyright 2009 Fabio Castelli <muflone@vbsimple.net>
License: GPL-2+ (please see the copyright file)
Description:
Gespeaker allows to play a text in many languages with settings for voice,
pitch, volume, speed and word gap.
Since version 0.6 it can use mbrola package and voices to obtain a more
realistic text reading experience.
Requirements:
Python >= 2.4
eSpeak (program + voices)
Python bindings for GTK2
Python bindings for Glade and libglade support
Python bindings for gObject
ALSA (aplay) or Pulseaudio server (paplay)
Support for mbrola:
If mbrola package and mbrola voices are available then the program could use
them. Just enable them from the preferences dialog.
Personal configuration
User's configuration will be kept under ~/.gespeaker
Please report any bugs in Gespeaker to the author:
Fabio Castelli <muflone@vbsimple.net>
Homepage:
Official project: http://code.google.com/p/gespeaker/
Italian project : http://ubuntrucchi.wordpress.com/progetti-projects/gespeaker/
librefdatool (0.1-1) saucy; urgency=low
* First snapshot from OHR sources
-- Javier D. Garcia-Lasheras (Javi) <javier@garcialasheras.com> Wed, 30 Oct 2013 01:26:07 +0100
This diff is collapsed.
#!/bin/bash
cd /usr/share/librefdatool/src
env python librefdatool.py
.\" $Id: gespeaker.1 0.7 2009-12-06 14:12 muflone $
.\"
.\" Copyright (c) 2009 Fabio Castelli
.TH GESPEAKER "1" "December 06, 2009"
.SH NAME
.B Gespeaker
\- A GTK+ frontend for eSpeak and mbrola
.SH SYNOPSIS
gespeaker
.SH DESCRIPTION
.PP
.B Gespeaker
is a GTK+ frontend for eSpeak and mbrola.
It allows to play a text in many languages with settings for voice, pitch,
volume, speed and word gap.
.PP
Since version 0.6 it can use mbrola package and voices to
obtain a more realistic text reading experience.
.PP
If mbrola was installed then the voices path must be selected from the mbrola
voices tab on the preferences page.
.SH FILES
Personal settings will be kept under ~/.gespeaker
.SH AUTHORS
.B Gespeaker
was written by Fabio Castelli <muflone@vbsimple.net>
.SH HOMEPAGE
International project: http://code.google.com/p/gespeaker/
Italian project: http://ubuntrucchi.wordpress.com/progetti-projects/gespeaker/
#!/usr/bin/env python
# This file is part of librefdatool. librefdatool is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright (C) 2013 Javier D. Garcia-Lasheras
#
from distutils.core import setup
from distutils.command.install_data import install_data
from distutils.dep_util import newer
from distutils.log import info
import glob
import os
import sys
__version__ = '0.1'
class InstallData(install_data):
def run (self):
install_data.run (self)
setup(
name='librefdatool',
version=__version__,
namespace_packages=['librefdatool'],
include_package_data=True,
maintainer='Javier D. Garcia-Lasheras',
maintainer_email='javier@garcialasheras.com',
license='LGPLv3',
url='http:www.owhr.org/projects/libre-fdatool',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: '
'GNU Lesser General Public License v3 or later (LGPLv3+)',
'Operating System :: POSIX',
'Operating System :: Microsoft :: Windows',
'Operating System :: MacOS :: MacOS X',
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Python Modules',
],
scripts=['librefdatool'],
data_files=[
('share/applications', ['data/librefdatool.desktop']),
('share/man/man1', ['man/librefdatool.1']),
('share/doc/librefdatool', ['doc/README', 'doc/changelog']),
('share/librefdatool/data/images', glob.glob('data/images/*')),
('share/librefdatool/data/icons', glob.glob('data/icons/*')),
('share/librefdatool/src', glob.glob('src/*.py')),
],
cmdclass={'install_data': InstallData}
)
This diff is collapsed.
# This file is part of librefdatool. librefdatool is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright (C) 2013 Javier D. Garcia-Lasheras
#
# Analysis class code is based in previous open source work:
# * mfreqz: by Matti Pastell
# * zplane: by Chris Felton
import numpy as np
from numpy import pi, log10
from scipy import signal
from matplotlib import pyplot as plt
from matplotlib import mlab
from matplotlib import patches
from matplotlib.figure import Figure
from matplotlib import rcParams
class Analysis():
'''This class include tools for LTI filter analysis,
sporting math models for studying coefficient quantization effects.
Note (limited to FIR filters)
'''
def analyze_zero_pole(self, c, p, q, filename=None):
'''Plot graphical zero/pole analysis in Z-plane:
* c: FIR filter coefficients array.
* filename: optional file for storing plot and not showing it.
'''
print('Plotting Z Analysis...')
# Quantize coefficients
d = np.zeros(len(c))
for ii in range(len(c)):
d[ii] = int(c[ii]*(2**(p+q-1)))
# Temporal assignation: only valid for FIR
print('Coefficients')
b1 = c
a1 = 1
print(b1)
print(np.max(b1))
b2 = d
a2 = 1
print(b2)
print(np.max(b1))
plt.figure('libre-fdatool analysis');
# get a figure/plot
ax = plt.subplot(111)
# create the unit circle
uc = patches.Circle((0,0), radius=1, fill=False,
color='black', ls='dashed')
ax.add_patch(uc)
# 1 - The coefficients are less than 1, normalize the coeficients
if np.max(b1) > 1:
kn1 = np.max(b1)
b1 = b1/float(kn1)
else:
kn1 = 1
if np.max(a1) > 1:
kd1 = np.max(a1)
a1 = a1/float(kd1)
else:
kd1 = 1
# 2 - The coefficients are less than 1, normalize the coeficients
if np.max(b2) > 1:
kn2 = np.max(b2)
b2 = b2/float(kn2)
else:
kn2 = 1
if np.max(a2) > 1:
kd2 = np.max(a2)
a2 = a2/float(kd2)
else:
kd2 = 1
# Get the poles and zeros
p1 = np.roots(a1)
z1 = np.roots(b1)
k1 = kn1/float(kd1)
p2 = np.roots(a2)
z2 = np.roots(b2)
k2 = kn2/float(kd2)
# 1 - Plot the zeros and set marker properties
tz1 = plt.plot(z1.real, z1.imag, 'bo', ms=10)
plt.setp( tz1, markersize=10.0, markeredgewidth=1.0,
markeredgecolor='b', markerfacecolor='b')
# 1 - Plot the poles and set marker properties
tp1 = plt.plot(p1.real, p1.imag, 'bx', ms=10)
plt.setp( tp1, markersize=12.0, markeredgewidth=3.0,
markeredgecolor='b', markerfacecolor='b')
# 2 - Plot the zeros and set marker properties
tz2 = plt.plot(z2.real, z2.imag, 'ro', ms=10)
plt.setp( tz2, markersize=10.0, markeredgewidth=1.0,
markeredgecolor='r', markerfacecolor='r')
# 2 - Plot the poles and set marker properties
tp2 = plt.plot(p2.real, p2.imag, 'rx', ms=10)
plt.setp( tp2, markersize=12.0, markeredgewidth=3.0,
markeredgecolor='r', markerfacecolor='r')
# set axis
plt.axis('scaled')
plt.ylabel('Imaginary Component')
plt.xlabel('Real Component')
plt.title(r'Zero-Pole Diagram (Blue=Float; Red=Int)')
plt.grid(True)
# show or store plot
return plt
def analyze_frequency_response(self, c, p, q, filename=None):
'''Plot graphical Magnitude/Phase analysis in frequency domain:
* c: FIR filter coefficients array.
* filename: optional file for storing plot and not showing it.
'''
# Quantize coefficients
d = np.zeros(len(c))
for ii in range(len(c)):
d[ii] = int(c[ii]*(2**(p+q-1)))
d = d/(2**(p+q-1))
print(c)
print(d)
wc,hc = signal.freqz(c,1)
hc_dB = 20 * log10 (abs(hc))
wd,hd = signal.freqz(d,1)
hd_dB = 20 * log10 (abs(hd))
plt.figure('libre-fdatool analysis');
plt.subplot(211)
plt.plot(wc/max(wc),hc_dB,'b')
plt.plot(wd/max(wd),hd_dB,'r')
plt.ylim(-150, 5)
plt.ylabel('Magnitude (dB)')
plt.xlabel(r'Normalized Frequency (x$\pi$rad/sample)')
plt.title(r'Magnitude response (Blue=Float; Red=Int)')
plt.grid(True)
plt.subplot(212)
hc_Phase = np.unwrap(np.arctan2(np.imag(hc),np.real(hc)))
hd_Phase = np.unwrap(np.arctan2(np.imag(hd),np.real(hd)))
plt.plot(wc/max(wc),hc_Phase,'b')
plt.plot(wd/max(wd),hd_Phase,'r')
plt.ylabel('Phase (radians)')
plt.xlabel(r'Normalized Frequency (x$\pi$rad/sample)')
plt.title(r'Phase response (Blue=Float; Red=Int)')
plt.grid(True)
plt.subplots_adjust(hspace=0.5)
return plt
This diff is collapsed.
# This file is part of librefdatool. librefdatool is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright (C) 2013 Javier D. Garcia-Lasheras
#
import numpy as np
from numpy import pi, log10
from scipy import signal
from matplotlib import pyplot as plt
from matplotlib import mlab
class control:
'''This class acts as control interface for filter parameters,
such as structure realization, fixed-point approximation...
Note (limited to FIR filters)
'''
def __init__(self):
'''This method provides initial filter parameters,
executing each set command with default values when
a new filter object is intantiated.
'''
self.setBus()
self.setScaling()
self.setStructure()
self.setModel()
self.setTrace()
self.setWorkspace()
self.setToolchain()
def setBus(self, busX=[1,15], busY=[1,15], busC=[1,15]):
'''assign the different bus width:
The value is given as a pair of natural numbers [p,q]:
- p is the number of bits representing the integer part.
- q is the number of bits representing the fractional part
There are three different configurable buses:
* busX: Input bit width
* busY: Output bit width
* busC: Coefficient bit width
'''
self.busX = busX
self.busY = busY
self.busC = busC
def setScaling(self, scalingX=16, scalingC=16):
'''assign the different FP scaling factor:
* scalingX: Input FP scaling factor (power of two exponent)
* scalingC: Coefficient FP scaling factor (power of two exponent)
'''
self.scalingX = scalingX
self.scalingC = scalingC
def setStructure(self, structure='firfilt'):
'''assign filter structure or realization.
Availability depends on python-to-HDL toolchain selection.
TBD: only "firfilt" structure is available
Future structures are type I/II direct forms, transposed...
'''
self.structure = structure
def setTrace(self, trace=False):
'''assign activation state for VCD file tracer.
If true, a *.vcd file will be generated by simulation process.
This file can be analyzed with third party tools such as GTKWave.
'''
self.trace = trace
def setModel(self, model='myhdl'):
'''assign HDL model, this is, the languaje for the toolchain.
When not selected the native/default value,
it relies on languaje conversion cogeneration & Icarus cosimulation.
For myhdl toolchain, valid values are [myhdl, verilog, vhdl, vhdl2]
TBD: this mechanism still has to be adapted for toolchain selection
and including migen an other tools (maybe GHDL for cosimulation).
'''
self.model = model
def setWorkspace(self, workspace='.'):
'''assign workspace folder for filter design and analysis.
By default, the path is the one where the librefdatool is called.
In this path, output files will be generated:
* VHDL, Verilog converted files
* VCD simulation files
'''
self.workspace = workspace
def setToolchain(self, toolchain='myhdl'):
'''Choose python-to-HDL toolchain.
By default, MyHDL is the toolchain in use.
TBD: migen toolchain will be developed in the near future
'''
self.toolchain = toolchain
# This file is part of librefdatool. librefdatool is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright (C) 2013 Javier D. Garcia-Lasheras
#
import sys
import os
from simcore import simcore
class core:
'''This class provides the principal librefdatool methods,
including running signal filtering with HDL models.
TBD: limited to FIR filter simulation
'''
def librefilter(self, b, a, x):
'''This method provides filter hardware simulation,
using a HDL description & a simulation engine
parametrized with the device control values.
* c: FIR filter coefficients array.
* x: Input signal array.
* return: simulated output signal
NOTE: the filter behaviour is tuned to match with:
scipy.signal.lfilter
(the purpose is direct comparision of outputs)
'''
# Save path and jump to workspace (TBD: if exists!!)
self.savedPath = os.getcwd()
os.chdir(self.workspace)
runner = simcore();
response = runner.simfilter(b, a, x,
self.structure, self.model, self.trace,
self.busX, self.busY, self.busC,
self.scalingX, self.scalingC)
# Return from workspace folder
os.chdir(self.savedPath)
return response
# This file is part of librefdatool. librefdatool is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright (C) 2013 Javier D. Garcia-Lasheras
#
# LibreFDATool Libraries
from core import *
from analysis import *
from control import *
class device(
control,
core,
Analysis):
'''This class instantiate a librefdatool filter device object.
A device represents an HDL model that can be widely parametrized
and used in python signal processing analysis and simulation.
The device class act as a main wrapper that includes function subclasses
TBD: only FIR filter is supported. General LTI system is in development.
'''
pass
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
# This file is part of librefdatool. librefdatool is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright (C) 2013 Javier D. Garcia-Lasheras
#
import warnings
import numpy as np
from numpy import pi, log10
from scipy import signal
from matplotlib import pyplot as plt
from matplotlib import patches, mlab
import sys, os, random
'''This module include the figure plotters used in Libre-FDATool.
'''
class Waveform:
def __init__(self, value=[0], label='waveform', color='#000000',
linestyle='-', marker='o', markersize=8):
self.value = value
self.label = label
self.color = color
self.linestyle = linestyle
self.marker = marker
self.markersize = markersize
def analyze_pole_zero(figure, b, a, p, q, grid):
'''Plot graphical zero/pole analysis in Z-plane:
* b: LTI transfer function Numerator.
* a: LTI transfer function Denominator.
* filename: optional file for storing plot and not showing it.
'''
print('Plotting Z Analysis...')
#TODO: use DAC / ADC like function, this is bad!!!
# Quantize coefficients
b2 = np.zeros(len(b))
for ii in range(len(b)):
b2[ii] = int(b[ii]*(2**(p+q-1)))
b2 = b2/(2**(p+q-1))
a2 = np.zeros(len(a))
for ii in range(len(a)):
a2[ii] = int(a[ii]*(2**(p+q-1)))
a2 = a2/(2**(p+q-1))
# Temporal assignation: only valid for FIR
print('Coefficients')
b1 = b
a1 = a
# 1 - The coefficients must be less than 1, normalize the coefficients
if np.max(b1) > 1:
kn1 = np.max(b1)
b1 = b1/float(kn1)
else:
kn1 = 1
if np.max(a1) > 1:
kd1 = np.max(a1)
a1 = a1/float(kd1)
else:
kd1 = 1
# 2 - The coefficients must be than 1, normalize the coefficients
if np.max(b2) > 1:
kn2 = np.max(b2)
b2 = b2/float(kn2)
else:
kn2 = 1
if np.max(a2) > 1:
kd2 = np.max(a2)
a2 = a2/float(kd2)
else:
kd2 = 1
warningMessage = ''
warnings.simplefilter('error')
try:
# Get the poles and zeros
p1 = np.roots(a1)
z1 = np.roots(b1)
p2 = np.roots(a2)
z2 = np.roots(b2)
except ValueError as exVE:
warningMessage = '%s' % exVE
except ZeroDivisionError as exZDE:
warningMessage = '%s' % exZDE
except RuntimeWarning as exRW:
warningMessage = '%s' % exRW
if warningMessage != '':
return False, warningMessage
else:
# Clear the figure
figure.clear()
# get a figure/plot
poleZeroSubplot = figure.add_subplot(111)