WiiLi Wiki frontpage Include your post in the News Get links Hoteles Quito
WiiLi.org Forum Index WiiLi.org
a new revolution
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Wiimote via Java
Goto page Previous  1, 2, 3 ... 26, 27, 28, 29, 30, 31  Next
 
Post new topic   Reply to topic    WiiLi.org Forum Index -> WiiremoteJ
View previous topic :: View next topic  
Author Message
Cha0s
Site Admin


Joined: 17 Jan 2007
Posts: 493

Digg It
PostPosted: Wed May 23, 2007 10:37 pm    Post subject:

Are you try to do this with a phone? WiiRemoteJ has this functionality built in, so if you're working with a PC, I don't see the point.

As for the code, it depends on what you're trying to do. I'm not quite sure I understand what you mean by "read data from the Wii Remote." Are you trying to information from the remote (such as accelerometer data, button data, etc), or are you trying to read the remote's EEPROM memory?
_________________
Cha0s
Back to top
View user's profile Send private message
dexter0



Joined: 26 Nov 2006
Posts: 11
Location: USA

Digg It
PostPosted: Thu May 24, 2007 2:54 am    Post subject:

Would anybody mind posting a link to information about playing arbitrary sound via the wiimote?

@Cha0s
Do you plan to open source this project?

Just out of curiosity, what is the name of the included song?
Back to top
View user's profile Send private message
Cha0s
Site Admin


Joined: 17 Jan 2007
Posts: 493

Digg It
PostPosted: Thu May 24, 2007 5:17 am    Post subject:

I don't think I'm going to open source the libraries. I do plan to create a project based on the libraries (a game) which I will open source. It will demonstrate how to use the libraries and provide a base for other developers. There should be info about playing arbitrary sound files in the docs for WiiRemoteJ. Note that they do have to be converted to the correct format first (which should be specified in the WiiRemoteJ docs), but after that. The song is "Tonight is the Night" by La Bouche.

The reason I'm not open-sourcing the libraries is that I'd like to maintain some form of quality control over the system. I'm afraid that tons of forks with willy-nilly methods added will result in a messy collection of libraries where nothing is standard. If you have requests for the library, please feel free to ask me. I plan to maintain this library for quite a while (I'm not going anywhere Razz ). If at any point, I become unable to continue maintenance, I'll definitely consider moving it to open source. The latest version of the library is almost ready for release. I've been hung up with a secret project of sorts (yes, Wii Remote related). I think people will like it, but I have to get it done first. Smile I hope to release the new project and a new version of WiiRemoteJ within the next week or two.
_________________
Cha0s
Back to top
View user's profile Send private message
Vixus



Joined: 29 Mar 2007
Posts: 56

Digg It
PostPosted: Thu May 24, 2007 12:26 pm    Post subject:

Hey Cha0s, I want to give this a go again, over my summer holidays. Can you give me a rundown of how to get this running?
Like... what will I need to download?

Yeah, sounding newbish, but I can't help it right now. Especially after that painful session with javabluetooth and stuff.
_________________
Java Coder... oh god...
Sensor bar designers... http://led.linear1.org/led.wiz


Last edited by Vixus on Thu May 24, 2007 2:24 pm; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
gangist2002



Joined: 12 May 2007
Posts: 6

Digg It
PostPosted: Thu May 24, 2007 1:23 pm    Post subject: @chaos

i´m still working on generally use of hid devices on mobile phones, pda´s which have a hid profile included.
for now i´m not sure which connect method(btl2cap, btspp) fits best for creating a connection between mobile phones and hid devices, i think btl2cap cause of low level ability.

ur question:
i hang on the connection to wiiremote:
i discover the hid service on wiiremote, get the address of the service over getConnectionURL() and connect to it over btl2cap.
now im ready to send.
using the send(byte[]) command, receive(byte) command, should get and send reports. BUT i dont know how these byte[] have to be look like.

so i need to know how i can convert the hexadresses written inside this wiki into byte arrays to send it.
another question is, how the communication between wiiremote and application work s in general. maybe u could send me a little diagramm which shows it.

another thx for today!
bye gangist2002
Back to top
View user's profile Send private message
dexter0



Joined: 26 Nov 2006
Posts: 11
Location: USA

Digg It
PostPosted: Thu May 24, 2007 2:44 pm    Post subject:

I am really just interested in the source for the PrebufferedSound method. I have been tinkering with DarwiinRemote on the Mac trying to add sound playing support to it. I would like to see how your method works so I can figure out how to get sound playing on the wiimote via DarwiinRemote.
Back to top
View user's profile Send private message
Cha0s
Site Admin


Joined: 17 Jan 2007
Posts: 493

Digg It
PostPosted: Thu May 24, 2007 11:15 pm    Post subject:

Ok... where to start.
Vixus: JavaBluetooth is kind of sucky. No USB adapters and just... meh in general. You're probably going to have to get Avetana. It has a free 14 day trial I believe. You can find it here. If someone could create a free JSR82 implementation for Windows or Mac, that would be great. I just don't have the talent to create the necessary native libraries. Anyways, once you have Avetana installed, the rest of the info you need should be in the readme.

gangist: The wiki says it all. As for hex in Java, you can specify hexadecimal notation with 0x. i.e. this is a command that would turn on all four lights:
Code:
byte[] command = new byte[]{0x52, 0x11, (byte)0xF0};

Note that any hex number that exceeds the max value of 127 (0x7F) will need to be cast to a byte. It'll work just fine then. If you can get this working on a phone, more power to you, but I've heard nothing but negatives from people trying previously. Mobile phone vendors don't like violating specs. Good luck!

dexter0: Ah, that's simple. Basically, I read a sound file (already correctly formatted) and put the bytes into data reports to be sent to the Wii remote (a byte array, just like a normal output command). To play the sound, I just sent reports at the correct rate (based on the frequency of the sound file). I used the proposition in the wiki discussion that sample rate = 48000/(3rd byte of speaker initialization).

Then I used this code (below). I scheduled it a rate of 1000/(frequency/20). Frequency is bytes/sec. I'm sending reports though, and each has 20 bytes of sound data. Therefore, each second, I need to send frequency/20 reports. That equation gives you separation of reports in milliseconds. Note this is for 8-bit sound. You can send twice as much data with the 4-bit reports. Your separation would therefore be doubled.
Code:

        TimerTask playTask = new TimerTask()
        {
            int index = 0;
            public void run()
            {
                try
                {
                    if (index < soundIn.numReports())
                    {
                        sendCommand(soundIn.getReport(index++));
                    }
                    else
                    {
                        LOGGER.info("Song time was: " + (System.currentTimeMillis()-startTime));
                        stopSound();
                    }
                }
                catch (IOException e)
                {
                    stopSound();
                }
                catch (Exception e){LOGGER.log(Level.WARNING, "Error stopping sound.", e);}
            }
        };

_________________
Cha0s
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    WiiLi.org Forum Index -> WiiremoteJ All times are GMT
Goto page Previous  1, 2, 3 ... 26, 27, 28, 29, 30, 31  Next
Page 27 of 31

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group