Interpolation Methods Comparison Project

Post your Gambas programming questions here.
Post Reply
User avatar
Cedron
Posts: 156
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Interpolation Methods Comparison Project

Post by Cedron »

InterpolationTesting-0.0.1.tar.gz
(98.74 KiB) Downloaded 480 times
Here is a quickie project that I whipped up to support answering

https://dsp.stackexchange.com/questions ... erpolation

It requires the FFTW library wrapper I wrote which can be found here:

https://forum.gambas.one/viewtopic.php?f=4&t=689

Once the program is running:

* Move the scroll bars to move the sample points.

1) Linear Interpolation - Black Line

2) Cubic Interpolation - Red Line

* Press the [Reset] button to rezero the signal

* Press the [Sine] button to set the signal to a single sine cycle

* Press the [DFT] button to add the DFT interpolation

3) Fourier Interpolation - Green Line

* Press the [Save] button to save the graph to a file (.png will be appended).

That's all it does...... For now.

Ced
.... and carry a big stick!
User avatar
cogier
Site Admin
Posts: 1160
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Interpolation Methods Comparison Project

Post by cogier »

I have had a go at this but there seems to be a problem. I have spent some time with FFTW but having added code to create the folders needed: -
If Not Exist(User.Home &/ "Gambas") Then Mkdir User.Home &/ "Gambas"
If Not Exist(User.Home &/ "Gambas/libGambas") Then Mkdir User.Home &/ "Gambas/libGambas"
If Not Exist(User.Home &/ "Gambas/libGambas" &/ ArgLibraryName) Then Mkdir User.Home &/ "Gambas/libGambas/" &/ ArgLibraryName
thePath = "~/Gambas/libGambas" &/ ArgLibraryName 
the "MaybeCompileLibrary: compile.sh not found." error keeps showing and the file is not in the folder.

Tips: -
When using Gambas to manipulate folders you don't need & "/". Gambas has &/ that will sort out the forward slashes for you.

This can be replaced: -
thePath = "~/Gambas/libGambas/" & ArgLibraryName & "/"

with either below the result will be the same
thePath = "~/Gambas/libGambas" &/ ArgLibraryName
or
thePath = "~/Gambas/libGambas/" &/ ArgLibraryName

Before you publish a Gambas program just run Project>Compile All. This will reveal that you have 2 variables in FFTW you have created that are not used.

Image
User avatar
Cedron
Posts: 156
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Re: Interpolation Methods Comparison Project

Post by Cedron »

FFTW-0.0.3.tar.gz
(14.68 KiB) Downloaded 452 times
Hi Cogier,

Thanks for the feedback. I really do appreciate you trying this out.

I've been a big fan of the ability to easily use shared libraries in Gambas, and a little dismayed that there is no official Gambas "packaging" methodology concerning them. I don't want to get involved in the messy business of Linux packaging. First, because it is messy, and second because it is Linux specific, even distro specific. Also, I think it is more appropriate to distribute the source code rather than a binary.

Thus, I have crafted a solution where the library is distributed with a "host" application, which will compile the library if necessary (RunSh.module), and has code in it which demonstrates the use of the library's functions. I don't think I can make it much more useful or easier than that.

The glitch in my plan is that I hard coded the assumption that the "host" project would be located in a "~/Gambas/libGambas" directory. This assumption was made due to the compile.sh script needing to have the directory as the current directory. Previously I hard coded the "cd directory" command as the first line in the .sh file (thus enforcing its location). I have changed that so the directory gets passed as a parameter.

Everything should work fine with the host application now.

This missing piece is how do I get the end user to either copy the .so, or make a link to the .so, in the system /usr/lib directory. This requires admin privileges which is something I don't feel comfortable adding to my code, and people would then be understandably wary of using it. If this step is taken, then the path specification in the Library statement is no longer necessary and just the library name can be used.

My new solution is to add a few comment lines near the Library declaration for how to create the soft link. Running the "host" application should now work anywhere. The soft link is only required in order for other applications to access the library simply by name instead of full path.

I've attached the new FFTW library "host" project. I would be grateful for it being independently tested and for any further recommendations.

On the other issue, I am aware of the "&/" operator. I am also aware that it is "syntax sugar" hiding a bit of processing. Therefore, if I know the outcome ahead of time, I will employ the simple "&" instead.

i.e. I will do ( x & "/" & y ) instead of ( x &/ y ) if I know x doesn't have a trailing slash and y doesn't have a leading slash. If either side is a string constant, it is more efficient to add the "/" to the constant than the "&".

Therefore, how I did it:

thePath = "~/Gambas/libGambas/" & ArgLibraryName & "/"

will be more runtime efficient than your two following examples. Plus, you neglected the trailing slash. Including that, and knowing it is there, eliminates the need for &/ downstream and allows for & instead.

In my VB days I used "Path" as a string variable suffix to indicate a directory name having a trailing backslash (Windows style) and "Dir" for a directory name without. The whole drive letter, now root path, thing made that necessary.

Of course, if I don't know, the &/ is a lot better than my own testing.

Thanks for the unused variable reminder. I try to do that. I also try to do a "Project/Clean" before making the archive too.

Ced
.... and carry a big stick!
User avatar
Cedron
Posts: 156
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Re: Interpolation Methods Comparison Project

Post by Cedron »

InterpolationDelay-0.0.1.tar.gz
(43.59 KiB) Downloaded 501 times
Here is another project demonstrating interpolation techniques. This one does not require the FFT library and should run as is.

The name is misleading as the delay calculations haven't been implemented yet.

Enjoy,

Ced
.... and carry a big stick!
User avatar
cogier
Site Admin
Posts: 1160
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Interpolation Methods Comparison Project

Post by cogier »

Hi Ced,

This version works with out any problems.
This missing piece is how do I get the end user to either copy the .so, or make a link to the .so, in the system /usr/lib directory. This requires admin privileges which is something I don't feel comfortable adding to my code, and people would then be understandably wary of using it. If this step is taken, then the path specification in the Library statement is no longer necessary and just the library name can be used.
You need the users password to gain admin privileges so you explain what your doing before asking for it. Have a look at "Sudo_solution" on the farm. There is a module/class you can copy to your own program that brings up an authentication request.

Image
User avatar
Cedron
Posts: 156
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Re: Interpolation Methods Comparison Project

Post by Cedron »

Hi Cogier,

Thanks for the tip. My concern isn't on how to do have the user enter the Admin password best, but should I do it. Or better stated, how can I avoid doing it, yet still make the process simple and transparent, i.e. understandable to the typical end user.

I've been on the 'net since nearly the start, well before it became public. In the beginning it was a wide open very trusting place. Unfortunately, as it became more popular it also attracted seedy operators. I'll be polite and leave my description at that.

I also worked on the same staff as system and network administrators when that was a very specialized occupation. In fact, I did a lot of that work myself (I automated a fair bit of it, but that is a different story). The ethos there was very strong on you don't give out root passwords. Very strong.

As a consequence, when I see the cavalier nature of how admin passwords are bandied about nowadays I cringe a little bit. Just pure gut reaction, because in most contexts they don't mean nearly what they used to.

I assume many others are like me and many others don't understand or care. When I give "sudo", "package manager", or the file explorer the admin password to do something, I am fairly confident it will not be abused. If I've just downloaded some piece of software from the web and it asks me for the password so it can "...", yeah, I don't trust it. What else could it do with that password?

I am reluctant to include admin password pass through in my releases for all the people who are like me in this regard.

Rather than having the instructions buried in the comments, I think I will create a popup with the intructions and the command line syntax that is easily copyable, so they only have to push a button, go to a terminal, paste, then press enter.

Ced
.... and carry a big stick!
Post Reply