Juce Tutorial - beginnings

haydxn,

I finished the 2nd chapter today. That Component stuff is really fun. Just to make sure I understood what’s going on, I created a very basic (4x4 buttons) calculator gui based on your ComponentBasics file. The calculator looks beautiful! (My appologies if that sounded corny, but it’s my 1st gui ever!)

Unfortunately, the calculator doesn’t do much. It can’t even display the numbers I press. Oh, well. I’m sure I’ll learn to do that very soon with your expanding tutorial :wink:

You’re making my C++ learning experience much more enjoyable. Thanks!

1 Like

Finished working throught the first 3 chapters, took about an hour and a half and I have to say it’s an awesome starting point. Took a page out of sojuman’s book and put together a simple calculator, just the basic 4 operators but it does the job, and looks the dogs cojones.

Thanks man, looking forward to chapters 4+.

1 Like

New chapter! Also slightly new format, as i’ve changed to OpenOffice and had to rejig it slightly. One benefit is that the pdf now has bookmarks.

There’s also a preliminary auto-contents, which i’ve yet to format properly. And an appendix with ‘answers’ for the tasks.

It still needs to be proof read, so sorry if some of it doesn’t read too well! Let me know if you have any problems. It’s late and I just wanted to get to the end of the chapter! I wouldn’t be surprised if i’ve done something really stupid in there, but hopefully i haven’t! i know that i put an example in about pink but forgot to say to actually put the code in… i’ll update it when i’ve proofread it properly!

same link as before…
Juce Tutorial PDF

1 Like

updated again, just refined chapter 4

1 Like

Haydxn

Thanks for the tutorial, I’ve worked through the whole article so far and it is a fantastic help. :smiley:

I found it really well written and pitched at just the right level of difficulty for me as a JUCE noob. Can’t wait to read more now you have made me a JUCE convert!!

1 Like

I finally found some time to get back to the tutorial. After reading ch 3 on Messages, I put some life into my calculator program by making it display corresponding # when a button is pressed. I also thought of a way to emulate a real calculator’s display sequence. You know, like it will display “1”, “12”, “123” when I press the buttons in 1, 2, 3 sequence. But, now I’m stuck. :cry:

How do I display the actual integer or float number using Label class? I only know how to display a string as shown in the tutorial. I tried reading juce reference, but there are so many classes! Is there another class I can/should use to emulate a calculator’s display screen? Help!

1 Like

[quote=“sojuman”]I finally found some time to get back to the tutorial. After reading ch 3 on Messages, I put some life into my calculator program by making it display corresponding # when a button is pressed. I also thought of a way to emulate a real calculator’s display sequence. You know, like it will display “1”, “12”, “123” when I press the buttons in 1, 2, 3 sequence. But, now I’m stuck. :cry:

How do I display the actual integer or float number using Label class? I only know how to display a string as shown in the tutorial. I tried reading juce reference, but there are so many classes! Is there another class I can/should use to emulate a calculator’s display screen? Help![/quote]

float f = 23.3f;

label.setText( String( f ) );

the String constructors are your friend.

1 Like

Thanks, Karbon! It’s so simple…I think I now have everything to complete this calculator program. I’m so glad I asked. :smiley:

1 Like

that’s a good point sojuman! i’ve only made you use the String class via the constructor so far, and that’s exactly where you do it - i guess i could point that fact out there too.

the chapter i’m currently working on is all about Strings, too :slight_smile:

1 Like

Well, I finally “finished” my calculator. What I set out to call it as “JuceyCalc” became “JuceyIntCalc”. Going through the 4 chapters of this tutorial with what I thought was a “simple” project was a really shocking and humbling experience.

Shocker #1: It took me much longer scratching my head in getting the calculator engine to work than GUI! GUI is so easy with JUCE. :smiley: No wonder haydxn wants to share this joy with everyone.

Shocker #2: Emulating a simple hardware calculator is not trivial at all! (at least with my limited programming skills :frowning: ). To me, the integer portion was easy, but the decimal or the fractional parts became non-exact business. The numbers were off slightly. I think complication is due to the fact that I have to build each number one digit (or one button) at a time. So, I decided to postpone this project and branch out to making an integer-only calculator. I can always complete the real calculator when I gain more experience.

Shocker #3: While struggling with this project, I couldn’t believe Jules alone created this JUCE library. All the things he had to sort out… and on top of that, he alone created Tracktion? :shock: I happen to be an owner of awesome Tracktion, and now Tracktion 2. Unfortunately, my music is in the same league as JuceyCalc so far :cry:

I couldn’t figure out how to post an image (how do I do this?), so I just created a link. It’s just a snapshot of JuceyIntCalc. It incorporates most of the stuff covered in haydxn’s tutorial.

http://public.fotki.com/sojuman/public/juce_applications/juceyintcalc.html

Jules, thanks for sharing your hard work with us. And haydxn, thanks for taking your valuable time teaching us this good stuff. I never expected my C++ learning would be slower than learning to build GUI!

1 Like

like this

[img]http://images12.fotki.com/v204/photos/7/747377/2881673/JuceyIntCalc-vi.jpg[/img]

1 Like

Karbon to the rescue again…thanks. :slight_smile:

1 Like

Chapter 5 added: Strings!

download PDF… (same link as before)

possibly the most incoherent chapter yet… had a run-in with ‘find and replace’ in my word processor too, making some words disappear! i hope i managed to fix them all, but let me know if some of it makes no sense! i’m sorry if this chapter seems to have less of a ‘structure’ than the others! it’ll likely be revised at some stage.

preview of the next three chapters…
6… juce::File (& tutorial app project 1: NotePad)
7… juce::Array
8… juce::XmlElement

1 Like

Thank you for sharing your tutorial Haydxn, I have now completed chapter 5 and finished my first ever fully functional program :smiley:

For the scientists amongst you it calculates the apparent permeability coefficients of substrate flux across a membrane…Hopefully…

I’m desperately awaiting the next chapter. If somebody told me a couple of weeks ago I would be getting this excited about C++ I would never have believed them but I am officially turning into a JUCE geek but it is amazing and the GUIs are beautiful!!

1 Like

Hi haydxn! Your tutorial is great so far! If you don’t mind, could I ask a question here in this thread?

You see, I’ve been able to compile your StartingPoint (the first one, just for the blank window), but it isn’t showing up when I run it. I’m on Linux, so I added the #define LINUX to the beginning, so now it compiles fine - I just don’t really know why it isn’t showing up (when I run it, it seems to work fine, then exits spontaneously after a few seconds). Any ideas (anyone)? Thanks!

1 Like

[quote=“Rellik”]Hi haydxn! Your tutorial is great so far! If you don’t mind, could I ask a question here in this thread?

You see, I’ve been able to compile your StartingPoint (the first one, just for the blank window), but it isn’t showing up when I run it. I’m on Linux, so I added the #define LINUX to the beginning, so now it compiles fine - I just don’t really know why it isn’t showing up (when I run it, it seems to work fine, then exits spontaneously after a few seconds). Any ideas (anyone)? Thanks![/quote]

Rellik,

I had similar problems at first with the tutorial crashing which was solved by changing:

   ~MainDialog() 
   { 
     JUCEApplication::quit(); 
   } 
 
   void closeButtonPressed () 
  { 
      delete this; 
   } 

to:


  ~MainDialog() 
   { 
  } 

   void closeButtonPressed () 
   { 
      JUCEApplication::quit(); 
   } 

Hope that helps

1 Like

Thanks for the idea, caco - my file seems to already be that way, though.

1 Like

I noticed that when I launch my program_name.exe file, it opens up a command prompt window 1st and then opens up my real program window (both debug and release versions). Is it possible to disable the command prompt window from popping up? Dis I setup the project incorrectly? I’m using MS Visual C++ 2005 Express on Windows XP. Thanks for your help.

1 Like

I remember that i had that same problem when i started. I think it came down to not having the project created properly in the first place.

At the moment (because my juce wizard isn’t 100% reliable yet), to make a new windows project:

  1. create a new project
  2. choose “Win32 Console Application”
  3. in the next screen click “Application Settings” on the left pane
  4. select both “Windows Application” and “Empty Project”
  5. click Finish

you’ll then also have to set the project properties to use the static runtime libraries (i.e. the “MultiThreaded” bit WITHOUT the “DLL” bit) as mentioned previously. i’ve made a wizard to make this stuff unnecessary, but i don’t want to push it yet as it’s tricky to install and the starter code is not perfect. If you want to try it though, look in the windows section of this forum.

Man, I knew I was doing something silly. I clicked “Empty Project” as in step 4 but didn’t click on “Windows Application”. All is well now.

Thanks again, haydxn, for keeping me straight. :smiley: