RE: Alex beep code example threads

  • From: "Ken Perry" <whistler@xxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sun, 8 Jun 2008 19:26:14 -0700


There is a bit more to it than unzipping.  The start is unzipping the
directory and you will get a directory like

Boost_1)_35_0 

You will also have to download bjam for the 386 platform.  After that you
put BJAM in your bin directory and then compile the libraries.  To compile
the libraries you go to the boost_1_35_0 folder and type something like the
following

Bjam --toolset=gcc --prefix=devc++ --layout=system install


Then you wait there will be errors don't fret over it.

Now you will note on my compile line I have --prefix=devc++ I don't know if
that is what your prefix should be I used --prefix=c:\mingw\ that is because
mingw has an include directory and a lib directory under mingw if your
devc++ main directory doesn't have include and lib directories you will need
to edit boost-build.jam and figure out what flags you need to set to get the
includes and libraries to go to the right place.  If you need help I can
help but I need to know where your devc++ main include and lib directories
are.

You can find the libraries and the bjam files at www.boost.org under the
getting started documentation.



Ken

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Alex Hall
Sent: Sunday, June 08, 2008 7:15 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: re: Alex beep code example threads

I do not think I have the boost libraries; my compiler gave me errors
starting on the "using namespace" line and after that it did not like
anything that referenced boost methods, plus it said that the directory for
boost files did not exist (I am paraphrasing here).  How do I get this
library, and is it simply a matter of unzipping a bunch of files to my
include path or is there more to it?

Have a great day,
Alex

> ----- Original Message -----
>From: "Ken Perry" <whistler@xxxxxxxxxxxxx
>To: <programmingblind@xxxxxxxxxxxxx
>Date sent: Sun, 8 Jun 2008 18:21:20 -0700
>Subject: Alex beep code example threads



>Alex I want to first say if I was doing this I would make sure to
not use
>just beep and I would code in a call to the wave function so you
could use a
>sound card.  I guess if the person didn't have a sound card you
could check
>for it and then use the pc speaker.  With that said I liked your
little
>project and though I would show you how it would be done with the
boost
>thread and date libraries.  Now if you don't have boost installed
I can tell
>you how to do that if you want to.  Here is the code that I made
though and
>it works.

>#include "boost/date_time/posix_time/posix_time.hpp"
>#include <boost/thread.hpp
>#include <boost/bind.hpp
>#include <iostream
>#include <windows.h
>#include <string

>using namespace boost::posix_time;
>using namespace boost::gregorian;
>using namespace std;

>enum PERIOD
>{
>  HOUR,
>  QUARTER,
>  HALF,
>  THREEQUARTER,
>};

>bool
>  beeps = true;

>void
>chime (PERIOD when)
>{
>  int
>    chimes = 0;                        // used to repeat chimes for the 
minutes
>  long LastChime;//used to not repeat when it has already chimed  //get 
> the current time from the clock -- one second resolution  ptime now = 
> second_clock::local_time ();

>//set the start last_time so that it doesn't ring instantly
>  if (when == HOUR)
>    LastChime = now.time_of_day ().hours ();
>  else
>    LastChime = now.time_of_day ().minutes ();

>  while (1)
>    {
>      Sleep (1000);
>      now = second_clock::local_time ();

>      if (beeps == true)
>       {
>         switch (when)
>           {
>           case HOUR:
>             if (LastChime != now.time_of_day ().hours ())
>               {
>                 for (long i = 0; i < now.time_of_day ().hours ();
i++)
>                   {
>                     Beep (244, 500);
>                     Sleep (500);
>                   }
>                 LastChime = now.time_of_day ().hours ();
>               }
>             break;
>           case QUARTER:
>             if ((LastChime != now.time_of_day ().minutes ()) &&
>                 (now.time_of_day ().minutes () == 15))
>               chimes = 1;
>             break;
>           case HALF:
>             if ((LastChime != now.time_of_day ().minutes ()) &&
>                 (now.time_of_day ().minutes () == 30))
>               chimes = 2;
>             break;
>           case THREEQUARTER:
>             if ((LastChime != now.time_of_day ().minutes ()) &&
>                 (now.time_of_day ().minutes () == 45))
>               chimes = 3;
>             break;
>           };                  //end switch

>         if (chimes > 0)
>           {
>             for (; chimes > 0; chimes--)
>               {
>                 Beep (488, 500);
>                 Sleep (500);
>               }
>             LastChime = now.time_of_day ().minutes ();
>           }
>       }                       //end if beeps true
>    }                          //end while

>}

>void
>input ()
>{
>  string
>    cmd;
>  while (1)
>    {
>      cin >> cmd;

>      if (cmd[0] == 'b')
>       {
>         beeps = true;
>         cout << "Beeps turned on." << endl;
>       }
>      else if (cmd[0] == 's')
>       {
>         beeps = false;
>         cout << "Beeps turned off." << endl;
>       }
>      else if (cmd[0] == 'q')
>       {
>         cout << "Turning off beeper." << endl;
>         exit (0);
>       }

>    }
>}

>int
>main ()
>{
>  boost::thread_group Tg;
>  Tg.create_thread (boost::bind (chime, HOUR));
>  Tg.create_thread (boost::bind (chime, QUARTER));
>  Tg.create_thread (boost::bind (chime, HALF));
>  Tg.create_thread (boost::bind (chime, THREEQUARTER));
>  Tg.create_thread (boost::bind (input));

>  Tg.join_all ();
>  std::cout << "Done! =)" << std::endl;
>  std::cin.get ();
>  return 0;
>}

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: