HFX Forum

General Discussion => General Discussion => Topic started by: godaigo2 on January 27, 2009, 05:26:05 PM

Title: Godaigo's plea for help!
Post by: godaigo2 on January 27, 2009, 05:26:05 PM
Hey guys, it's been a while! I see Cobby's been back on... Anyway, I had to set up a new account to get back on the board? My main godaigo account won't allow me access to  anything. I suppose ya'll are just trying to get rid of me, but an e-mail would have worked if that's the case!  ;D Anyway, any help appreciated....
Title: Re: Godaigo's plea for help!
Post by: godaigo2 on January 27, 2009, 05:45:28 PM
I suppose I should have been clearer, it allows me to log on but everything is restricted. I can't view boards, or even my own profile. Cheers...
Title: Re: Godaigo's plea for help!
Post by: Cobra on January 28, 2009, 08:35:59 AM
Try your account again man .. you should be good to go.
Title: Re: Godaigo's plea for help!
Post by: godaigo on January 28, 2009, 01:19:12 PM
Thanks man! I think I was starting to go through withdrawals! I used to check the board almost daily, so I'll have a lot of catching up to do. Thanks Cobby!
Title: Re: Godaigo's plea for help!
Post by: Cobra on January 30, 2009, 09:31:18 AM
haha i wouldn't worry about missing out on too much.. Place has been a bit dead.
Title: Re: Godaigo's plea for help!
Post by: godaigo on January 30, 2009, 02:20:50 PM
That's too bad... Any talk of resurrecting some of the old ideas for projects, etc?
Title: Re: Godaigo's plea for help!
Post by: Cobra on February 03, 2009, 06:54:33 AM
Not sure man.. everyone seems to be busy with their jobs and shit.. however i am working on an Anti Bot-Net project at the moment.

So if your any way handy with C# would be glad of the help.. haha ;)
Title: Re: Godaigo's plea for help!
Post by: godaigo on February 05, 2009, 02:20:18 PM
Unfortunately I haven't really played with C# at all. Java, C, and C++... don't know if I would be any help, but let me know!
Title: Re: Godaigo's plea for help!
Post by: benthehutt on April 29, 2009, 12:13:14 PM
Hey guys! I ran into the same problem and supposed my account got deleted, but it's back up now. Sweet!

As far as projects go, give us more specs on that Anti-botnet project you're working on, Cobra. What specific things are you wanting this to do?
Title: Re: Godaigo's plea for help!
Post by: benthehutt on April 29, 2009, 03:20:05 PM
One more thing: I've noticed a lot of us simply don't post because we don't know when new posts are on the forum. I don't know how many of you use RSS feeds, but after some researching at simplemachines.org, I found there is a default RSS feed activated at http://forum.hfactorx.org/index.php?type=rss;action=.xml . Now I'm updated via Google Reader.
Title: Re: Godaigo's plea for help!
Post by: godaigo on April 29, 2009, 08:45:28 PM
Sweet, I hooked that up for my Bloglines! Just got done with a boring little piece of Java code too... What have you been up to Ben?
Title: Re: Godaigo's plea for help!
Post by: benthehutt on April 29, 2009, 10:31:56 PM
Nice! It's been a long time, man! I've just been finishing up school. I've got two days left then I'm out for good. I've also been working for a place in Chicago doing Flash/AJAX programming. As far as projects go I've recently been doing some physics engine development in AS3. I thought about posting some stuff here, but it doesn't seem like an HFX kinda thing.

What about you? And we need to get some collaboration going on some project.
Title: Re: Godaigo's plea for help!
Post by: godaigo on April 30, 2009, 02:32:45 PM
I've actually just enrolled in school again. I figured a third degree couldn't hurt. So I'll finish up the CS and get that done with. Mostly I've been working with Java recently, nothing too terribly complicated though. It would be great to get something going though. I would love to get back into the swing of things and do some serious coding before I forget everything! Keep me posted if you have any ideas!
Title: Re: Godaigo's plea for help!
Post by: benthehutt on April 30, 2009, 04:24:11 PM
Well I'm starting some research into writing a synthesizer in Java. I'm all in to math, so I'd like to try my hand at Fourier synthesis and some related stuff. Do you have any experience with low level Java sound programming? I see audio synthesis libraries all around, but I'd like to write a Fourier synthesizer from scratch.
Title: Re: Godaigo's plea for help!
Post by: godaigo on May 02, 2009, 01:16:29 AM
I don't really, other than I started to look into what sound libraries were out there for my last final. I was planning on adding some simple sound effects to an app. but ran out of time, it was all extra credit stuff. I did see a lot of classes that would allow you to import various sound file types, pretty basic code, but I'm not 100% sure that it's the type of thing that you're talking about? I'll do some checking and get back to you!
Title: Re: Godaigo's plea for help!
Post by: godaigo on May 02, 2009, 01:18:21 AM
Ben, something like this perhaps? http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=17
Title: Re: Godaigo's plea for help!
Post by: benthehutt on May 02, 2009, 11:46:43 AM
Yeah! That's a pretty sweet app. I'm more interested in actual synthesis than just adding sound files to an application. Anyway, I started some work on this, but I've got some questions on Java as a whole. What is the difference between Java and J2EE? Also, what good is the Runnable class? I've seen some examples where a guy instantiates a Runnable object and I don't know what the point was.

Here is my code so far. It's pretty simple, it just generates a sine wave and a square wave and plays them back. But let me know if I'm doing anything in Java that's stupid (I'm using Eclipse 3.4.1 Ganymede):


import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.LineUnavailableException;

import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;

public class BasicSound {

// CD Quality audio (well, almost)
public final float SAMPLE_RATE = 44100;

// Main GUI component
JFrame mainFrame;

public static void main( String[] args ){
BasicSound my_sound = new BasicSound();
my_sound.showDialog();
}

public BasicSound(){
setUpDialog();
}

public void setUpDialog(){
    // Main frame
    mainFrame = new JFrame("Pure Wave Generator");
    mainFrame.setSize( 300, 300 );
    Container content = mainFrame.getContentPane();
    content.setBackground(Color.white);
    content.setLayout(new FlowLayout());
   
    // Frequency slider
    final JSlider slider_hertz = new JSlider( JSlider.HORIZONTAL, 20, 20000, 440 );
    slider_hertz.setPaintLabels( true );
    slider_hertz.setToolTipText("In Hertz");
    slider_hertz.setBorder( new TitledBorder( "Frequency" ) );
    content.add( slider_hertz );
   
    // Sine wave button
    final JButton btn_play_sine = new JButton( "Play Sine Wave" );
    btn_play_sine.addActionListener( new ActionListener(){
    public void actionPerformed( ActionEvent actionEvent ){
    try{
    System.out.println("Play sine wave at " + slider_hertz.getValue() + " hertz.");
generateSineWave( slider_hertz.getValue() );
}catch( LineUnavailableException err ){
System.out.println("Line is unavailable.");
}
    }
    } );
    content.add( btn_play_sine );
   
    // Square wave button
    final JButton btn_play_square = new JButton( "Play Square Wave" );
    btn_play_square.addActionListener( new ActionListener(){
    public void actionPerformed( ActionEvent actionEvent ){
    try{
    System.out.println("Play square wave at " + slider_hertz.getValue() + " hertz.");
generateSquareWave( slider_hertz.getValue() );
}catch( LineUnavailableException err ){
System.out.println("Line is unavailable.");
}
    }
    } );
    content.add( btn_play_square );
   
    mainFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}

public void showDialog(){
    mainFrame.setVisible( true );
}

// Generate a sine wave at a specified frequency
public void generateSineWave( float hertz ) throws LineUnavailableException{
    byte[] buf = new byte[1];
   
    AudioFormat af = new AudioFormat( SAMPLE_RATE, 8, 1, true, false );
   
    SourceDataLine source_dl = AudioSystem.getSourceDataLine( af );
    source_dl.open( af );
   
    for( int i=0; i < SAMPLE_RATE; i++ ){
      double angle = i / ( SAMPLE_RATE / hertz ) * 2.0 * Math.PI;
      buf[0]=( byte )( Math.sin( angle ) * 100 );
        source_dl.write( buf, 0, 1 );
}

System.out.println("Finished playback.");

source_dl.start();
source_dl.drain();
source_dl.stop();
source_dl.close();
}

// Generate a square wave at a specified frequency
public void generateSquareWave( float hertz ) throws LineUnavailableException{
    byte[] buf = new byte[1];
   
    AudioFormat af = new AudioFormat( SAMPLE_RATE, 8, 1, true, false );
   
    SourceDataLine source_dl = AudioSystem.getSourceDataLine( af );
    source_dl.open( af );
   
    for( int i=0; i < SAMPLE_RATE; i++ ){
      double angle = i / ( SAMPLE_RATE / hertz ) * 2.0 * Math.PI;
      buf[0]=( byte )( ( Math.sin( angle ) > 0 ) ? 100 : -100  );
        source_dl.write( buf, 0, 1 );
}

System.out.println("Finished playback.");

source_dl.start();
source_dl.drain();
source_dl.stop();
source_dl.close();
}

}


Also, what is the difference between an ActionListener and an EventListener?

Any help would be appreciated. Thanks!