High Level language with Low level Graphics [closed] - graphics

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I am looking for a high level language which will still allow me to work directly with graphics. I want to be able to modify screen pixels, for instance. But I do not want to write huge amounts of code for each operation. I want simple one line commands for graphics somewhat like those listed below. What are some programming languages which would have these features?
Possible pseudocode:
Screen.clear
Graphics.line(4,5,20,25).color=green
Circle(centerx,centery,radius)

Depending on what you want to do (ie, how complex do you need to get?) Processing is a very high-level, graphics-focused environment. Note, however, that it seems to be focused on the fixed function OpenGL pipeline, which is deprecated (though arguably the easiest and most intuitive way to get started).
Processing is built in Java, runs in web browser (or from your desktop), and abstracts most of the initialization and cleanup code required to use OpenGL.
Edit
I've just noticed your comment that says you're not an experienced programmer. In that case, I'd recommend starting with Processing. Once you get the hang of it, move on to Python.
Another, slightly more complex, option is Python. Python is very powerful, fairly easy to pick up (depending upon your prior development experience), and widely supported. It'll also allow you to use shaders and other features from the 21st century, and is cross-platform See this link for PyOpenGL, the first Python OpenGL site that popped up in google.
Then, there's C# + OpenTK. This can get pretty complex pretty quickly, but is very powerful, and since it's compiled (under .NET or Mono), can potentially give you better performance than Python.
Finally, for close-to-bare-metal performance, C++ is unbeatable, though arguably the most complex of these options, with a significant learning curve. However, most of the example code you'll find online is in C++, which can be an issue if you're not using C++ and aren't comfortable reading it.

Using Qt you can create QImage objects and draw on them usign QPainter.
You've of course pixel control using that abstraction level, but you can also access the underlying memory directly using bits() and bytesPerLine() methods thus accessing the image memory directly.
The format that is easiest to use to do fast special computations is in my opinion QImage::Format_ARGB32 with 32 bits per pixel.
Qt is a C++ library portable on may OSs and platforms, and bindings are available for many very high level languages (e.g. Python).

Related

Which FRP package to choose? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I'm just starting to look into the world of Functional Reactive Programming in Haskell, and I would like to experiment with GUI programming (with gtk, because of substantial binding) in a reactional setting.
Now, I've been looking a bit at Grapefruit, Reactive-Banana and Buster, and I would like any testament to the joy/horror of using any one or other package.
All I have is these preliminary oppinions:
I don't mind doing some of the binding of the FRP package to gtk myself, as I have an ambivalet feeling about the abstracted backend idea (that Grapefruit has)..
While I find type theory interesting, I also value simple encodings for actual programs, which seems to put grapfruit-records a bit off..
That is, unless of course some of you persuades me to think otherwise :-)
If you just want to use regular FRP, and stay close to the GUI framework rather than using a "pre-made" abstraction over it, reactive-banana is the most viable option, in my opinion. It's explicitly geared around binding to existing frameworks, is designed for "real-world" use (not doing anything too experimental, semantically, that could cause problems), and so on.
You can take a look at reactive-banana-wx to see how to bind an event-based framework to reactive-banana. It's very simple; I wrote a quick binding to Gtk2Hs once (lost the code now, unfortunately), and the file didn't go over 50 lines. It was almost a direct transliteration of the reactive-banana-wx code.
I would recommend against using Buster, for the simple reason that it hasn't been updated since 2009, and doesn't build on GHC 7.
Other "production-oriented" FRP frameworks are sodium (similar to reactive-banana, but it has dynamic event switching (which is coming to reactive-banana soon, but isn't in yet) and a concept of "partitions" for concurrency; however, it's just come out and hasn't seen adoption yet) and netwire (arrowised FRP, quite a different creature to reactive-banana and sodium).
I've been experimenting with FRP myself and so far the only one that's worked for me is Reactive-Banana. I never looked into Grapefruit or most of the others because they were out of date and didn't seem like they were likely to be updated or supported at all. I did briefly look at netwire, but frankly all the arrow theory in it put me off and I had a lot of trouble figuring out how to do even simple things.
In contrast I've managed to get a pretty good set of bindings to SDL written in Reactive-Banana with only a few hiccups along the way. Another thing in favor of Reactive-Banana is that Heinreich is very active in the community and will often provide helpful answers when you run into problems. Just look through the various reactive-banana questions on here and you'll see he's responded to quite a few of them and he's usually very active in FRP discussions in the Haskell mailing lists.

FORTRAN graphic library on Linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I started learning FORTRAN and need graphic library to plot output
As I'm not familiar with FORTRAN environment, I wanted to ask for recommendation
I'm used to matplotlib, and preferably looking for something similar. Similar in means of available features, and workflow concepts
Searching through Synaptic it seems like PGPLOT is the way to go
PS I know I could wrap FORTRAN code in Python in different ways
I've used PGPLOT, dislin and PLPLOT. In this era I'd use dislin or PLPLOT. PGPLOT was last updated in 2001 and only has a FORTRAN 77 interface, which can be used with Fortran 90/95/2003 but the compiler won't be able to check that your calls have the correct arguments. The other two have Fortran 95 interfaces. Of dislin and PLPLOT, I think dislin to be better documented. dislin also provides widgets for GUI input. dislin is free for some uses; for business uses one is supposed to purchase a license. PLPLOT is open source under the LGPL.
Yes, PGPLOT is an option.
You may also want to look into PLplot: http://plplot.sourceforge.net/
DISLIN - supports several platforms and languages (python included).
Have you considered using VisIt or similar software? VisIt can visualise very large datasets and has a mechanism for in-situ visualization with the libsim library. See this presentation for a nice introduction to in-situ visualization with VisIt: http://calcul.math.cnrs.fr/Documents/Ecoles/Data-2011/CouplageSimulationVisualization.pdf.
See here for the libsim api.
Finally, a few additional notes.
While you sate
I'm used to matplotlib, and preferably looking for something similar.
Similar in means of available features, and workflow concepts
using libsimwould be quite different, but it is very powerful.
and
Right now just general graphic package to plot intermediate data
products. If I do well then perhaps I'll look for package that handles
large data sets. But if I get there I'll probably know what to use
till then.
Rather than write a solution now and then change it to deal with large data sets, why not just write a scalable solution now?
Not familiar with FORTRAN plotting but in most languages a quick way to do easy-to-program static graphics is not to use a library at all but to find that language's equivalent of the C "system()" call, find a program that will do the plotting and write the equivalent of:
1. Write plot data to file.
2. Do system call running plot program with data file argument.
3. [Optional] Delete plot data file.
This gives your program the full functionality of the plot program with minimal programming. The plot data and plot program are likely to be in the disk cache so it's all in memory. It's also easily debugged.
People underestimate the system() call - it gives access to a vast array of functionality including scripting. Some would say it's not efficient or "pure" but the user won't care and it will often drastically reduce the amount of programming necessary. Don't reinvent the wheel.
You can use:
PLplot: http://plplot.sourceforge.net/
gtk-fortran. It is a GTK / Fortran binding which offers also an interface to PLplot: https://github.com/vmagnin/gtk-fortran/wiki

Resources for audio DSP beginners? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I am interested in audio DSP programming, but not in any specific language. I seem to recall a website that had recipes for common DSP application (compressors, limiters, et cetera), but I can't seem to find it in my bookmarks or via Google.... does anyone here know of such a place?
Short of that, I am not very mathematically literate but I have a strong sense for algorithms and logic, as well as working knowledge of a few different languages. What are some good resources for the beginning DSP programmer?
Thanks
Tom
Was the website www.MusicDSP.org?
This question: Recommended books for developing audio/music applications? lists a few books which may be relevant to you.
I'm going to suggest The Audio Programming Book from MIT Press. Lots of recipes and example code.
For general signal processing I'd recommend MatLab. MatLab has the libraries you need, good documentation and it was basically designed for this sort of thing. Now, I've not used it for audio signal processing, just sensor data and some data mining, but I think it's a good start to getting used to stuff like Fourier Transforms + various filters/windows.
Here's the MatLab documentation for the discrete fourier transform- really good:
http://www.mathworks.com/help/techdoc/ref/fft.html;jsessionid=x9xhNglGm1DdQNTBzyhj8DGb50QVnvCGxf3KmvM3xbnPlMbxGBQT!-779685318
If you are looking for:
1. programming languages: I would recommend MATLAB or Octave. Octave is free, and almost the same as MATLab in every respect. If you are going to be using MATLab, you can take a look at the MATLab exchange. The site contains good examples of code for solving good problems, audio DSP and otherwise.
Books: A good book to begin in DSP theory is the one by Proakis and Manolakis. Also, for a breezy tutorial to DSP, the Scientist and Engineer's Guide to DSP is one of the best. You can download the book for free and in some parts it is actually like reading a novel. Gets you upto speed with most issues that you might face in dsp and does so very intuitively with little Math.
Applications: There are tons of applications out there! And with the increasing power, processing and otherwise, of smartphones and the like, intensive DSP calculations that were once the preserve of very powerful computers are now being done on the device itself. Once you are proficient enough, you may even consider contributing to different open-source projects.
Adapted from: Where can I find good tutorials on writing audio DSP filters (lowpass, etc)?
A good filter cookbook is http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt
I also recommend getting Lyon's Understanding Digital Signal Processing. I am a bit biased, though, since I was a reviewer for the second edition (but I think a third edition came out recently).
Also check out Digital Audio Signal Processing and DAFX:Digital Audio Effects, both by Udo Zölzer.
Making Audio Plugins gives a very gentle start without too much DSP math.
The tutorials start from the very beginning and show how to create this synthesizer:
There's a lot of stuff for Python in music, although most of them don't emphasize DSP. Also, some parts of the language standard lib such as the itertools can be handy.
Implementing algorithms such as the ones declared that aren't part of the packages there (e.g. a limiter, a compressor) might be easier when thinking on Python iterables instead of taking care of segregating the sample-based and block-base approach manually, and that makes it easier to make the algorithm used in real time directly. AudioLazy is a Python DSP package made to have a simple API, maybe it'll help as basic structures such as Z-Transform filters are done directly by their equation, and any Python iterable can be used as audio. Perhaps seeing its code can be helpful, as well. (Disclosure: I'm the author of this package)
About a book, I like the DAFx, which is extremely practical and audio-oriented. You might consider implementing the algorithms on there (the MATLAB code) in Python.
For a more solid knowledge on DSP, you should read the book "Discrete-Time Signal Processing", by Oppenheim and Schafer.

How can I use functional programming in the real world? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Functional languages are good because they avoid bugs by eliminating state, but also because they can be easily parallelized automatically for you, without you having to worry about the thread count.
As a Win32 developer though, can I use Haskell for some DLL files of my application? And if I do, is there a real advantage that would be taken automatically for me? If so, what gives me this advantage? The compiler?
Does F# parallelize functions you write across multiple cores and CPUs automatically for you? Would you ever see the thread count in Task Manager increase?
How can I start using Haskell in a practical way, and will I really see some benefits if I do?
It seems like the book Real World Haskell is just what you're looking for. You can read it free online.
F# does not contain any magic pixie dust that will pass functions off to different CPUs or machines. F#/Haskell and other functional programming languages make it easier for you to write functions that can be processed independent of the thread or CPU they were created on.
I don't feel right posting a link here to a podcast I participate in. It seems a little off, but in the Herding Code episode, where we talked with Matt Podwysocki, we asked the same question and he gave some interesting answers. There are also a lot of good links relating to functional programming in that episode. I found one link titled "Why Functional Programming Matters". That may provide some answers for you.
This might also be interesting:
"Real World Functional Programming"
Examples are in F# and C#, but the theory is fairly generic.
From what I've read (pre-release) it is definitely interesting, but so far I think it is making me want to stick more and more with C#, using libraries like Parallel Extensions.
You didn't mention, but I'm assuming, that you're using C++. One potentially easy way to get into functional is via C++/CLI to F#. C++ contains "magic pixie dust" (called IJW: It Just Works) to allow you to call into and out of managed code. With this, calling F# code is almost as simple as it is from C#.
I've used this in one program (FreeSWITCH), which is written entirely in C/C++. With a single managed C++/CLI (use the /clr switch), it magically transitions into managed code, and from there, I can go load my F# plugins and execute them. To make things even easier for deployment, F# can statically link all its dependencies, so you don't need to deploy the F# runtime files. One other thing that makes CLR code attractive is that you can pass managed code (delegates) to C code, and the runtime automatically makes a thunk for you.
If you decide to go the Haskell way, the feature you'll be looking for is FFI: Foreign Function Interface. However, I don't think it'll give you the same level of integration as C++/CLI with F#.
I'm currently learning Haskell myself. When you start out learning it, it doesn't seem very intriguing, because the learning experience is nothing like learning a language like C#.
It's a whole new world, but I noticed I could write very very complex expressions in just a few lines of code. When I looked back at the code, it was much more concise; it was small and tight.
I'm absolutely loving it! You can indeed write real-world programs that will be smaller, easier to maintain, and much more complex than most other languages allow. I vote for you to learn it!!
Since you mention Win32 and DLLs, I presume you're working with unmanaged code. In that case, GHC will work very well for you. Late last year I wrote a DDE server under Windows using FFI to talk to the Microsoft DDE libraries, and, surprisingly, it was an extremely pleasant experience (especially given that I'm a Unix guy).
Haskell's FFI is powerful (even supporting, e.g., callbacks into Haskell functions from C or other libraries), and having Haskell's type checking when writing C-level code is like a dream come true.
That last point is one of the major advantages of Haskell: the type system is amazing. That said, it's like any powerful tool; it needs time and effort to make good use of it.
So yes, it is possible to start out writing small bits of code in Haskell that link into the rest of your code (though you may find it easier to start with small Haskell programs that link to your other code), and it's well worth spending a fair amount of time learning about this and using it wherever you can. You may end up like me, planning a fairly major project tightly integrated with Windows code (in my case, a sophisticated Excel add-in) in Haskell.

Best Java Obfuscation Application For Size Reduction [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
An important part of mobile development, especially when you are talking about mobile games, is dealing with the application size restrictions. Some devices enforce their own size limits, while all the carriers have their own size requirements for applications to be released in their deck space.
My question is, is there a java obfuscation application that gets better size reduction results than the other java obfuscation apps that are out there?
I use Proguard because it is the default Netbeans obfuscator and you can get fairly good size reduction results out of it (by the way, the version of Proguard that comes with Netbeans 6.1 is 3.7. There are newer versions that get even better results, I recommend getting the latest). But, I'm interested in what else is out there and whether they do a better job than Proguard.
My Conclusion:
I appreciate the responses. Carlos, your response was enough to convince me that Proguard is the current way to go. I could still be convinced otherwise, but don't feel bad with my current setup.
I have also had some issues with proguard obfuscating and running on some phones, but not too many. I was always able to fix the problem by not using the Proguard argument "-overloadaggressively". Just something to keep in mind if you are experiencing odd behavior related to obfuscating.
Thanks again.
I also prefer ProGuard for both it's size reduction and breadth of obfuscation - see http://proguard.sourceforge.net/. I don't necessarily have size constraints other than download speeds, but haven't found anything that shrinks further.
When it comes to J2ME and obfuscation it pays to be a bit cautious. Proguard is the best choice because of the many years it has been in development, and the many bugfixes that it has received. I remember the version transition between 2.X and 3.X and how it broke many of my (then) employer builds. This happened because some of the changes that enabled more size savings also broke the class files in subtle ways in some handsets, while being perfectly fine in others and on desktop JVMs.
Nowadays Proguard 3.11 is the safest choice in obfuscators. 4.XX is probably fine if you don't have to support very old handsets.
Strange that no one remembered that ProGuard can not just shrink and obfuscate the code, but optimize as well. The last versions allow to specify several passes for optimization (by default there is a single pass), I may specify, say, 9 passes.
After I decompile my classes I can hardly recognise them, ProGuard restructures a lot of method calls. All it takes is just a bit of tweaking this wonderful app. So I think ProGuard is the way to go, just don't forget to adjust it a little. It also has a very nice manual.

Resources