View mode: basic / threaded / horizontal-split · Log in · Help
February 06, 2003
Unicode: Japanese Study Program
I'd like to write a program that randomly cycles through a bunch of Japanese
words and phrases. The program should display a word or phrase and play an
MP3 file with appropriate pronunciation. It should run automatically as a
drill or interactively as a test. The test mode should allow
fill-in-the-blanks and multiple choices. It should be implemented with a
graphical user interface as I will be using this to help my son (5) with his
Japanese studies.

I'm not looking for someone to do this for me (I would me out of my mind to
along those lines), however I cannot provide an example of what I've done
because I do not know where to begin. Any suggestions would be greatly
appreciated.

I though this would be a great way to start learning how to actually
program, and help my son along the way. If someone could point me in the
right direction, I'll try to find my way from there. Thanks a million.

Andrew
February 06, 2003
Re: Unicode: Japanese Study Program
The following is an attempt to identify all the characters available in D.
As far as I can see, unicode has not yet been implemented, so it will not
solve it's purpose. However there are some things wrong with the program.
I'd like to ignore all nonprintable characters, but am unsure how to
accomplish that. The documentation provides the following in the string
module, however it doesn't seem to work (or am I applying it incorrectly?):

   const char[] whitespace;
" \t\v\r\n\f"

==========
import stream;
import string;

int main()
{
 for (int i; i < 2000; i++)
 {
   if(!whitespace(i))
     printf("%10d: %c", i, cast(wchar)i);
   //if(i%5) : does not work, why?
   if(i%5 == 0)
     printf("\n");
 }
 return 0;
}
February 07, 2003
Re: Unicode: Japanese Study Program
for MP3 playback, here's some links to MS's info on MCI
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/mc
i_04dv.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/mc
i_25k5.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/mc
i_04dv.asp
and a couple of examples in other langs of how to use the above info.
http://www.codeproject.com/audio/mp3player.asp
http://www.vbcode.com/asp/showzip.asp?ZipFile=mcisamp.zip&theID=205

however if you've not programmed b4, I would start with something a little
easier
currently there are no complete ports of the win32 API
but you may need bits which can be found on ...
http://www.digitalmars.com/d/windows.html
http://www.opend.org/dig/index.html.
http://www.codemoon.com/cm/artlist.php?index=main
http://www.l8night.co.uk/mwynn/d/win32api.html

I don't think the winmm lib bits are ported yet, the headers are in
/dm/include awaiting the port :)
the rest is going to be up to you.


"Andrew Edwards" <aedwards@spamfreeamerica.com> wrote in message
news:b1unpa$294t$1@digitaldaemon.com...
> I'd like to write a program that randomly cycles through a bunch of
Japanese
> words and phrases. The program should display a word or phrase and play an
> MP3 file with appropriate pronunciation. It should run automatically as a
> drill or interactively as a test. The test mode should allow
> fill-in-the-blanks and multiple choices. It should be implemented with a
> graphical user interface as I will be using this to help my son (5) with
his
> Japanese studies.
>
> I'm not looking for someone to do this for me (I would me out of my mind
to
> along those lines), however I cannot provide an example of what I've done
> because I do not know where to begin. Any suggestions would be greatly
> appreciated.
>
> I though this would be a great way to start learning how to actually
> program, and help my son along the way. If someone could point me in the
> right direction, I'll try to find my way from there. Thanks a million.
>
> Andrew
>
>
>
February 07, 2003
Re: Unicode: Japanese Study Program
"Mike Wynn" <mike.wynn@l8night.co.uk> wrote in message
news:b1utle$2c2a$1@digitaldaemon.com...
> http://www.digitalmars.com/d/windows.html

Attempting to compile the winsamp.d file mentioned in the above link,
produces the following errors:

winsamp.obj(winsamp)
Error 42: Symbol Undefined _CreateFontA@56
winsamp.obj(winsamp)
Error 42: Symbol Undefined _SelectObject@8
winsamp.obj(winsamp)
Error 42: Symbol Undefined _SetTextAlign@8
winsamp.obj(winsamp)
Error 42: Symbol Undefined _TextOutA@20
--- errorlevel 4

Should I have linked it to another file?

Thanks
February 07, 2003
Re: Unicode: Japanese Study Program
I link against
kernel32.lib user32.lib gdi32.lib COMCTL32.LIB ole32.lib oleaut32.lib
uuid.lib
saves you having to worry what your doing.

(those should just be in gdi32.lib, so `dmd winsamp gdi32.lib` works [just
tested it])

Mike.

"Andrew Edwards" <aedwards@spamfreeamerica.com> wrote in message
news:b1uvdr$2cs9$1@digitaldaemon.com...
> "Mike Wynn" <mike.wynn@l8night.co.uk> wrote in message
> news:b1utle$2c2a$1@digitaldaemon.com...
> > http://www.digitalmars.com/d/windows.html
>
> Attempting to compile the winsamp.d file mentioned in the above link,
> produces the following errors:
>
> winsamp.obj(winsamp)
>  Error 42: Symbol Undefined _CreateFontA@56
> winsamp.obj(winsamp)
>  Error 42: Symbol Undefined _SelectObject@8
> winsamp.obj(winsamp)
>  Error 42: Symbol Undefined _SetTextAlign@8
> winsamp.obj(winsamp)
>  Error 42: Symbol Undefined _TextOutA@20
> --- errorlevel 4
>
> Should I have linked it to another file?
>
> Thanks
>
>
February 07, 2003
Re: Unicode: Japanese Study Program
Not only it doesn't seem to work, it also doesn't seem to compile :)
Compiler message:
e1.d(8): function expected before (), not 'char[6]'

That's where Pascal's set would kick in!

"whitespace" is a string, containing all characters which are considered
to be whitespace. To check whether some certain character is a
whitespace, you can use "find" from string module. Description:

---8<---
int find(char[] s, char c)

Find first occurrance of c in string s. Return index in s where it is
found. Return -1 if not found.
--->8---

so that you do:

if (find(whitespace, i) == -1){
  // code here only executes if i is not whitespace character code
}

An alternative were to use a bit-array, which would be much like Pascal 
set. An advantage of a set, is that it's always a bit array of a minimun 
size of stack slots, which also returns "false" for all entries outside 
its range. To limit the overuse of sets, they only allow up to 256 
entries though, that is you can't match the whole unicode table with a 
set. Imagine how huge this set would become! Definately too large to be 
passed on the stack :)

In general, you might consider using Delphi or Java for such a task, 
because there are no beginner's ways to D yet... You have to know C (or 
rather a common subset of C and C++, which is popular and sufficent) 
well to get along with D. Besides, there are good beginers' books to 
Java and Delphi and tons of libraries. You won't be able to freely and 
simply use C libraries in D for a while, forget about C++ ones. Delphi 
is my favorite, although i miss a lot of features in it which i find in 
D. But D is not as clean and lacks of some Pascalese as well.

-i.


Andrew Edwards wrote:
> The following is an attempt to identify all the characters available in D.
> As far as I can see, unicode has not yet been implemented, so it will not
> solve it's purpose. However there are some things wrong with the program.
> I'd like to ignore all nonprintable characters, but am unsure how to
> accomplish that. The documentation provides the following in the string
> module, however it doesn't seem to work (or am I applying it incorrectly?):
> 
>     const char[] whitespace;
> " \t\v\r\n\f"
> 
> ==========
> import stream;
> import string;
> 
> int main()
> {
>   for (int i; i < 2000; i++)
>   {
>     if(!whitespace(i))
>       printf("%10d: %c", i, cast(wchar)i);
>     //if(i%5) : does not work, why?
>     if(i%5 == 0)
>       printf("\n");
>   }
>   return 0;
> }
> 
>
February 07, 2003
Re: Unicode: Japanese Study Program
Using MS interfaces for MP3 playback is the worst choice. Consider using
a multi-plafrorm audio system:
http://www.fmod.org
http://www.s2.org/midas/
http://www.mikmod.org/ (Open-Source)

And only for Windows (and possibly x86 Linux):
http://www.un4seen.com/
(BASS library)

All of these libraries are free for non-commercial use. I guess they
play MP3 and OGG and a number of other formats. Check the documantation
to be sure they support the formats you want. If you find any other
cross-platform library, just tell me.

I've tried FMOD. It's very easy to use, and should fit very well. Before
using any chosen system in DMD, please make sure you were able to
compile and run a simple example with DMC, so that you won't run into
linking problems. I shall help you with that.

-i.


Mike Wynn wrote:
> for MP3 playback, here's some links to MS's info on MCI 
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/mc
>  i_04dv.asp 
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/mc
>  i_25k5.asp 
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/mc
>  i_04dv.asp and a couple of examples in other langs of how to use the
>  above info. http://www.codeproject.com/audio/mp3player.asp 
> http://www.vbcode.com/asp/showzip.asp?ZipFile=mcisamp.zip&theID=205
> 
> however if you've not programmed b4, I would start with something a 
> little easier currently there are no complete ports of the win32 API
>  but you may need bits which can be found on ... 
> http://www.digitalmars.com/d/windows.html 
> http://www.opend.org/dig/index.html. 
> http://www.codemoon.com/cm/artlist.php?index=main 
> http://www.l8night.co.uk/mwynn/d/win32api.html
> 
> I don't think the winmm lib bits are ported yet, the headers are in 
> /dm/include awaiting the port :) the rest is going to be up to you.
> 
> 
> "Andrew Edwards" <aedwards@spamfreeamerica.com> wrote in message 
> news:b1unpa$294t$1@digitaldaemon.com...
> 
>> I'd like to write a program that randomly cycles through a bunch of
>> 
>> 
> 
> Japanese
> 
>> words and phrases. The program should display a word or phrase and 
>> play an MP3 file with appropriate pronunciation. It should run 
>> automatically as a drill or interactively as a test. The test mode 
>> should allow fill-in-the-blanks and multiple choices. It should be 
>> implemented with a graphical user interface as I will be using this
>>  to help my son (5) with
> 
> his
> 
>> Japanese studies.
>> 
>> I'm not looking for someone to do this for me (I would me out of my
>>  mind
> 
> to
> 
>> along those lines), however I cannot provide an example of what 
>> I've done because I do not know where to begin. Any suggestions 
>> would be greatly appreciated.
>> 
>> I though this would be a great way to start learning how to 
>> actually program, and help my son along the way. If someone could 
>> point me in the right direction, I'll try to find my way from 
>> there. Thanks a million.
>> 
>> Andrew
>> 
>> 
>> 
> 
> 
>
February 07, 2003
Re: Unicode: Japanese Study Program
On Fri, 07 Feb 2003 13:11:10 +0100
Ilya Minkov <midiclub@8ung.at> wrote:

> Using MS interfaces for MP3 playback is the worst choice. Consider
> using a multi-plafrorm audio system:
> http://www.fmod.org
> http://www.s2.org/midas/
> http://www.mikmod.org/ (Open-Source)
> 
> And only for Windows (and possibly x86 Linux):
> http://www.un4seen.com/
> (BASS library)
> 
> All of these libraries are free for non-commercial use. I guess they
> play MP3 and OGG and a number of other formats. Check the
> documantation to be sure they support the formats you want. If you
> find any other cross-platform library, just tell me.
> 
> I've tried FMOD. It's very easy to use, and should fit very well.
> Before using any chosen system in DMD, please make sure you were able
> to compile and run a simple example with DMC, so that you won't run
> into linking problems. I shall help you with that.

For Windows, Linux and IRIX, there is Audiere (http://audiere.sf.net),
LGPL licensed and very nice. There is of course a potential issue in
that the latest versions are 100% C++, I'm not sure how well that'd
work with D. (My guess is not at all.) But if you can get it to work, it
supports MP3, Ogg Vorbis, Ogg Flac, MOD, S3M, IT, XM, wav and probably
some others.

-- 
Theodore Reed (rizen/bancus)       -==-       http://www.surreality.us/
~OpenPGP Signed/Encrypted Mail Preferred; Finger me for my public key!~

"[...] for plainly, although every work of art is an expression, not
every expression is a work of art." -- DeWitt H. Parker, "The Principles
of Aesthetics"
February 07, 2003
Re: Unicode: Japanese Study Program
> For Windows, Linux and IRIX, there is Audiere (http://audiere.sf.net),
> LGPL licensed and very nice. There is of course a potential issue in
> that the latest versions are 100% C++, I'm not sure how well that'd
> work with D. (My guess is not at all.) But if you can get it to work, it
> supports MP3, Ogg Vorbis, Ogg Flac, MOD, S3M, IT, XM, wav and probably
> some others.

Most libraries are written with C linkage, so that they can be used from 
C and from C++.
I looked at it a bit and i've got a bad feeling. It doesn't seem to be 
accessable from C. Another issue is a number of functions for which you 
need to fix prototypes - in FMOD you only need three or so, i guess 
that's somewhere about the bottom. Of course, anything can be hacked. 
But it would be much.
However, the links page of the project is very interesting. Some shall 
be very useful to me later. Thanks.

http://tuo.planet-d.net/skysound/
may be intereisting for Andrew's purposes.

But i can't promise soon help with anything except for FMOD.

-i.
February 09, 2003
Re: Unicode: Japanese Study Program
"Ilya Minkov" <midiclub@8ung.at> wrote in message
news:b20s1v$chv$1@digitaldaemon.com...
> Most libraries are written with C linkage, so that they can be used from
> C and from C++.

Of course, that's why D is designed to be able to directly access such
libraries!
Top | Discussion index | About this forum | D home