Tuesday, October 27, 2015
Casio SA-10 + FPGA = Audio Synthesis
First, yes, I'm alive... You just need to know where to look for (Hint: Flickr or dA).
Second, no, this won't be a long post.
Third, new project!
https://github.com/zebarnabe/music-keyboard-vhdl/
Regarding this last point, I'm building an audio synthesizer from my dead Casio SA-10 (non-destructive modifications, might be able to repair it in the future) and my old Digilent Nexys 2 FPGA board...
So far, so good... It works as a proof of concept, though I need to make it properly since to ensure polyphony I instantiated 32 basic synthesizers instead of properly serialize the processes ... processing everything at the same time is always fun in a FPGA.
Currently taken logic is at 10%, I guess I can make it a lot better by serializing the output mixer alone... or lower the precision... 144kHz sampling with 16bits and 32 channels is a bit overkill, specially when the PWM controller only does 8 bits.
Tuesday, March 8, 2011
Super Scribble (EDITED: 10/03/2011 v2)
You can download the latest package installer .sis file from here:
Downloads - super-scribble - Project Hosting on Google Code
If you have a Nokia with a touchscreen and a Symbian OS and ever tried Python I'm sure you know Scribble, a small sample application that shows Python touchscreen interaction by providing a simple doodling application.
One of the things you may have noticed it, it's the limited feature set, you have an eraser and a pencil, you also have a color picker from where you can pick a few colors, thankfully you can save the doodles or notes you make on it.
There are other applications for Symbian touch devices that deliver some similar features, some allow for zoom and a better color picker, but nothing else...
Here are some of the doodles I did on scribble's unmodified state:
As you may have noticed, they are only B&W pictures, this is because rarely any of the colors provided are truly useful.
I've used scribble for quite some time and this week I spent my time practicing Python and PyS60 API.
I messed up with pretty much everything on Scribble's source code, so I added a number of features to it, namely mix brush, smudge tool, opacity, RGB sliders to pick color and brush color history. All this while trying to maintain the performance and smoothness of the application.
With those changes I manage to do these doodles in little time:
Of course there is still room for improvement, like the ability to open and edit images (and by consequence the support for bigger images and removal of the white stripe on the bottom of the images)
You can download the application (sis and python source) from here (tested in Nokia 5800 XpressMusic, should work in N97, 5530, 5230, X6 or any other Symbian touch device that has PyS60 2.0.0 installed and working)
I'll perhaps post a video later explaining what each of the interface areas does... If you're going to try it, you should at least know that touching the red bordered rectangle on the will pick the rectangle fill color for the brush.
Have fun!
PS:
R.I.P. Nokia, if you didn't know Nokia it's now a Microsoft's partner and while Nokia isn't dead, Symbian S60 5th and S^3 will kinda meet a dead end, S40 will continue to survive in lower end devices where nokia still have a valuable market share.
EDIT (10/03/2011):
I improved it (currently version 0.6.x) but didn't released it yet - probably will release a video together with the new version (that will probably be version 0.7.x).
v0.6.0 features the following additions:
- Support for any size of drawing (as long as the memory handles it)
- Support for Zoom
- Move tool (allows one to move the canvas by dragging it)
- Color picker tool, picks a tool from canvas to use in brush
Stay tuned for updates :]
Tuesday, November 16, 2010
Line of code of the day #5
Store Procedures (SPs), as you may not know, are supported by mySQL for quite some time, however not quite perfectly as you might expect.... On SPs, you basically build a wrap box around one or more SQL statements, you can set variables, use the usual SQL stuff.... in my case i was using a SELECT, like i did for the rest of the dozens of SPs i did before, i was implementing a page like feature in the CMS, for that LIMIT clause is god send, but guess what.... in SPs you can't use non-constant integers in LIMIT parameters... yes.... you can use the arguments of the SP anywhere, except on the LIMIT clause...
So ... "How to solve it?" that would be the question... one way would be using a prepared statement, like this:
CREATE PROCEDURE `fooTable`.`sp_fooTableList` ( limit_arg int )
BEGIN
SET @sql = concat('SELECT * FROM `fooTable` LIMIT ', limit_arg);
PREPARE STMT FROM @sql;
EXECUTE stmt;
END
An obvious problem with this, is that it broken the extra security provided by SPs... but it is a valid workaround.... quite simple as well.... but because this prepared statement kinda defeat the purpose of having a nicely wrapped SQL statement, i found a way of doing it without recurring to it, i say found and not invented, credit goes to Gert Brigsted, it's easy to follow and understand how and why it works:
CREATE PROCEDURE `fooDB`.`sp_fooTableList` ( limit_start, limit_end )
BEGIN
SET @rownum:=0;
SELECT *
FROM (
SELECT ( @rownum:=@rownum+1) AS Rownumber, `fooTable`.*
FROM `fooTable`
ORDER BY `fooTable`.`mooCol` DESC
) AS t
WHERE Rownumber > limit_start AND Rownumber <= limit_end;
END
It looks messy, but it works... sure, it has some impact on performance, but that's the price to pay for security... until LIMIT clause accepts variables as parameters.
Perhaps you are thinking, "That surely is, or will be, fixed in current iterations of mySQL" ... you are right it is, in versions 5.5.6 and 6.0.14, it is 'fixed' ... But not all servers allow you to change mySQL version installed... so, I guess you may run into this problem and have to use one of the above workarounds...
As a side note, this was submitted as bug #11918 by 13 July 2005 and 'solved' by 24 September 2010 .... more than 5 years to 'fix' this 'bug' ... i use quotes because wasn't exactly a bug but more like a non-feature...
Hope it helps someone out there bashing at "ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near: s_limit, e_limit;"
Thursday, June 18, 2009
Line of code of the day #4
solution[i] = solution[j] | (~0)&(1<<z)
The most familiarized with C and pointers will notice that if i is not related in bounds with j value (or vice-versa) something really bad will happen with memory access/write... the lovely usual segmentation fault or worse... the line should have look like this:
solution[j] = solution[j] | (~0)&(1<<z)
Or in a more compact form:
solution[j] |= (~0)&(1<<z)
I lost 3h to find where the error on my code was... you see, when instead of j the i was there I was writing in some area, that area was where a pointer inside a struct was, at first I though the error was in functions that manipulate variables of that struct... when I noticed something very strange when I switch some entries on struct... it looked like something impossible to happen, but after I've done it some stuff worked, so struct control looked fine... only answer would me that I was modifying struct data unknowing it... after a bunch of printf's (like... everywhere) I tracked the error down... cost me a lot of time... and now I 'only' have to finish some algorithmic stuff that is implemented, polish some of the code and optimize some memory accesses...
Well... good coding... i hope you have better luck than me...
Tuesday, June 9, 2009
Line of code of the day #3
(( f[(m & 0xF0) | (val & 0xF0) >> 4] >> 3) >> (f[(m & 0x0F)<< 4 | (val & 0x0f )] >> 3 ) & 0xF)
Oh, this code is just for 8bits, a simple expansion allows me to use it for 32bits (with look-up table taking up 2Mb)... and no... I won't explain what is in f table has... and yes... I might screw up with the parentesis... I didn't compile that piece of code, but tested it manually instead... it should work... efficiency wise it's better that scan all bits one by one...
You can now commit suicide.
PS: By reading this you agree that i'm not responsible for any harm occoured both physically or mentally when reading the text above... really...
Tuesday, June 2, 2009
Line of code of the day #2
Tuesday, April 28, 2009
Line of code of the day
Tuesday, March 24, 2009
VHDL considerations...
While programming in VHDL can't be considered a very easy deal, there are certain things on it that are very easy to do... i lost 2 days with one of those things...
Making a crash course into VHDL sintax (and assuming that you know how a computer works in hardware terms), you control bits in vhdl... yes... bits... the simplest think in computers world... of course that it isn't very easy to do complex things of a thing so simple, but anyone understands that shifting bits is just picking a bunch of them and putting them a little bit aside.
In VHDL you can create arrays - vectors - of bits, and you can access each bit or a pack of them by indexing them, sounds scary, but it's very easy actually, one with no knowledge in programming should have no problem doing a static shifter in vhdl.
To index bits, you need to 'create' them... well ... there is a lot of mambo-jambo in VHDL for doing declalations, and while i mastered most of VHDL sintax i still fail in the most basic stuff (well, i'm always learning from mistakes but it doesn't seem enough xD).
Well... lets say you have a array of bits, better saying a vector, in vhdl it is called std_logic_vector, and it's simple a vector of std_logic elements.. std_logic elements are the representation of a signal value in hardware (well, kinda) they can be 1, 0 or other ugly stuff you really don't wanna know...
Ok... we have our vector puppy in a signal, this should be human readable (or i'm loosing my human side):
signal puppy : std_logic_vector (31 downto 0);
So puppy has 32 bits ordered like 31 down to 0... how nice...
if you want a bit from puppy, you just do like this:
puppy(3)
And that is bit number 3... it's 4th bit if you count from right, since there is a bit 0... easy to get right?
Now harder! >:D you want... the 8 first bits... that will be hard, right?
puppy(7 downto 0)
Damn... was too easy... well... this is being great but grabbing bits without interact with them is a bit... worthless... well... you have a nice operator for concatenate bits! So now we can make our shifter... to concatenate bits you just use & operator like so:
'0'&"0000001"
So ... easy to get ('0' is a bit with zero value .... and "0000001" is a vector of bits) ... so 8 bits with the least significant bit (if you consider the right the least significant bit) at '1'
Now ... how to shift? You should get it now without any help, let's shift our puppy 8 bits to right!
"00000000"&puppy(31 downto 8)
Easy... right? I mean... you couldn't fail that... no way.... right? I did fail at doing that... and lost 2 days of work >:(
I wanted to shift one bit to right, i did like this (taking puppy as an example):
'0' & accu(30 downto 0)
That simply replaces the last bit with '0' ... >___>''
PS: Sorry for the length of this post...
Friday, February 27, 2009
Pong... yay...
Monday, February 23, 2009
FPGA - Nexys2
Thursday, January 8, 2009
RTSS@2007 CiberMouse
So... i won the run... like ... i went to cheese and come back without hit anything... sure, took a while ...is kinda funny to see how near i come to the start point (mouses have 2 engines that have error and inertia associated when energy applied) so is not easy for such thing to happen...
Well ... it's 6:10am ... i think i go take some rest...




