|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On April 03 2013 09:15 CorsairHero wrote:man...double pointers  Anyone going for a C programming job should look them up. I keep hearing about this. Are you talking about pointers to a pointers in general, or the branch reduction trick?
|
What are your opinions about using Dreamweaver in general?
|
In general? Never use it, pretty much as simple as that 
Its going to generate shitty HTML, far worse than you could write by hand, so you'll want to write it by hand instead. And then if you're writing it by hand, I don't see why you would want to use Dreamweaver as your editor. Just use a decent text editor.
|
On April 03 2013 09:53 CecilSunkure wrote:Show nested quote +On April 03 2013 09:15 CorsairHero wrote:man...double pointers  Anyone going for a C programming job should look them up. I keep hearing about this. Are you talking about pointers to a pointers in general, or the branch reduction trick? Just pointers in general. For some reason, I had always thought you could change the pointer itself when passing it in as a function parameter. Apparently a double pointer is needed to be passed in. I shouldn't be complaining though because the documentation is online. It was just something I didn't use in my classes or in practice at my internship.
|
On April 03 2013 13:56 Blisse wrote: What are your opinions about using Dreamweaver in general? Using it in general is fine. Using it specifically is BLEAAARRGHGHGH:
Seriously, don't use Dreamweaver. HTML is not that hard to learn.
|
On April 03 2013 13:56 Blisse wrote: What are your opinions about using Dreamweaver in general? There's literally no reason to use it. HTML is very simple to write and Dreamweaver generates crappy code. Sometimes there's a reason to use generated HTML (if you use ASP.NET Web Forms for example), but there's never a reason to use a graphical IDE for normal websites.
|
Can anyone tell me a good place to find exercises/assignments that require you to use more advanced features of C? Things like goto pointers to functions, pointers to arrays, pointers to structures and storage allocation? I really need to do things in order for my mind to process them. Just reading about them won't help me much.
Also, I've been taking courses on Algorithms on Coursera: https://www.coursera.org/course/algs4partI https://www.coursera.org/course/algs4partII
These courses are done by Princeton and include quizzes and assignments (programming questions given by employers!) to test your knowledge. Programming in these courses are done in Java, but there is no set deadline for any of the content because you don't actually get a certificate of accomplishment or anything for them. Apparently these are the more basic of the algorithm courses, and Stanford University will offer some higher level algorithms courses also on Coursera, which do offer a certificate. The content seems interesting so far, coming from someone who took a Mechatronics course (Our course involves programming on devices that have limited computational power and memory! Let's NOT make them take a course on how to make programs efficient!). I'm also hoping to take their Hardware/Software interface course later this month. Might be good to add those to the OP.
|
Hey can anyone help me with this.. thing? Java volume thing.
I'm trying to record audio and then determine if the audio had a higher volume, was mute, or had a lower volume. Some guy on the interwebs said he was able to use this code to determine muteness. http://stackoverflow.com/questions/5800649/how-to-detect-silence-when-recording-in-java
Just help explain what this code is doing and how I can use it please.
package bemukan.voiceRecognition.speechToText;
import javax.sound.sampled.*; import java.io.*;
public class RecordAudio { private File audioFile; protected boolean running; private ByteArrayOutputStream out; private AudioInputStream inputStream; final static float MAX_8_BITS_SIGNED = Byte.MAX_VALUE; final static float MAX_8_BITS_UNSIGNED = 0xff; final static float MAX_16_BITS_SIGNED = Short.MAX_VALUE; final static float MAX_16_BITS_UNSIGNED = 0xffff; private AudioFormat format; private float level; private int frameSize;
public RecordAudio(){ getFormat(); }
private AudioFormat getFormat() { File file = new File("src/Facebook/1.wav"); AudioInputStream stream; try { stream = AudioSystem.getAudioInputStream(file); format=stream.getFormat(); frameSize=stream.getFormat().getFrameSize(); return stream.getFormat(); } catch (UnsupportedAudioFileException e) {
} catch (IOException e) {
} return null; }
public void stopAudio() {
running = false; }
public void recordAudio() {
try { final AudioFormat format = getFormat(); DataLine.Info info = new DataLine.Info( TargetDataLine.class, format); final TargetDataLine line = (TargetDataLine) AudioSystem.getLine(info); line.open(format); line.start(); Runnable runner = new Runnable() { int bufferSize = (int) format.getSampleRate() * format.getFrameSize(); byte buffer[] = new byte[bufferSize];
public void run() { int readPoint = 0;
out = new ByteArrayOutputStream(); running = true; int sum=0; while (running) { int count = line.read(buffer, 0, buffer.length); calculateLevel(buffer,0,0); System.out.println(level);
if (count > 0) { out.write(buffer, 0, count); } } line.stop(); } }; Thread captureThread = new Thread(runner); captureThread.start(); } catch (LineUnavailableException e) { System.err.println("Line unavailable: " + e); System.exit(-2); } }
public File getAudioFile() { byte[] audio = out.toByteArray(); InputStream input = new ByteArrayInputStream(audio); try {
final AudioFormat format = getFormat(); final AudioInputStream ais = new AudioInputStream(input, format, audio.length / format.getFrameSize()); AudioSystem.write(ais, AudioFileFormat.Type.WAVE, new File("temp.wav")); input.close(); System.out.println("New file created!"); } catch (IOException e) { System.out.println(e.getMessage()); } return new File("temp.wav"); } private void calculateLevel (byte[] buffer, int readPoint, int leftOver) { int max = 0; boolean use16Bit = (format.getSampleSizeInBits() == 16); boolean signed = (format.getEncoding() == AudioFormat.Encoding.PCM_SIGNED); boolean bigEndian = (format.isBigEndian()); if (use16Bit) { for (int i=readPoint; i<buffer.length-leftOver; i+=2) { int value = 0; // deal with endianness int hiByte = (bigEndian ? buffer[i] : buffer[i+1]); int loByte = (bigEndian ? buffer[i+1] : buffer [i]); if (signed) { short shortVal = (short) hiByte; shortVal = (short) ((shortVal << 8) | (byte) loByte); value = shortVal; } else { value = (hiByte << 8) | loByte; } max = Math.max(max, value); } // for } else { // 8 bit - no endianness issues, just sign for (int i=readPoint; i<buffer.length-leftOver; i++) { int value = 0; if (signed) { value = buffer [i]; } else { short shortVal = 0; shortVal = (short) (shortVal | buffer [i]); value = shortVal; } max = Math.max (max, value); } // for } // 8 bit // express max as float of 0.0 to 1.0 of max value // of 8 or 16 bits (signed or unsigned) if (signed) { if (use16Bit) { level = (float) max / MAX_16_BITS_SIGNED; } else { level = (float) max / MAX_8_BITS_SIGNED; } } else { if (use16Bit) { level = (float) max / MAX_16_BITS_UNSIGNED; } else { level = (float) max / MAX_8_BITS_UNSIGNED; } } } // calculateLevel
}
I don't understand what getformat() is doing. Why would you create a file and then get its format? Seems kind of unnecessary.
I think recordaudio() records audio from my primary speakers. But how do I stop the recording?
stopaudio() looks like it stops recording. So I can start a video, start the recording, sleep for 10 seconds, and call this to stop the recording.
and getAudioFile() looks like it creates an audio file from the output stream generated by recordaudio()
calculateLevel()... how do I use this? I think it's used for calculating volume but I don't know how.
edit: I see it is using the bemukan library and now I am having troubles building that. edit: it's built. I just had to add the two external jars that came with the rar but I haven't gotten any further in my goals. edit: nvm maybe I can try this some more. edit: I figured it out woot! :D edit: now I just need to set the line from mic to speakers edit: ^this is not possible sound sucks in java. To elaborate, you can do this, but then you need a line in cable that then plugs into your computer's speakers. There is also software in certain OS that let you do the same thing. But I'm writing this for other machines so these aren't options.
Java runs on a vm and is therefore incapable of intercepting sound before it hits the speakers. It's only capable of getting input sounds like line in or microphone :/ I'm not going to convolute this problem with another language.
|
man I suck so bad at Java, I worked so hard for my 2 other jobs and missed most of the class and now I'm facing a serious problem with this Java class. Anyone know where I can find tutor online for 1 on 1 question & answer. I'd really appreciate it.
|
On April 04 2013 16:57 Nazza wrote:Can anyone tell me a good place to find exercises/assignments that require you to use more advanced features of C? Things like goto pointers to functions, pointers to arrays, pointers to structures and storage allocation? I really need to do things in order for my mind to process them. Just reading about them won't help me much. Also, I've been taking courses on Algorithms on Coursera: https://www.coursera.org/course/algs4partIhttps://www.coursera.org/course/algs4partIIThese courses are done by Princeton and include quizzes and assignments (programming questions given by employers!) to test your knowledge. Programming in these courses are done in Java, but there is no set deadline for any of the content because you don't actually get a certificate of accomplishment or anything for them. Apparently these are the more basic of the algorithm courses, and Stanford University will offer some higher level algorithms courses also on Coursera, which do offer a certificate. The content seems interesting so far, coming from someone who took a Mechatronics course (Our course involves programming on devices that have limited computational power and memory! Let's NOT make them take a course on how to make programs efficient!). I'm also hoping to take their Hardware/Software interface course later this month. Might be good to add those to the OP. Don't be lazy, read a book bro.
|
On April 07 2013 05:04 tuho12345 wrote: man I suck so bad at Java, I worked so hard for my 2 other jobs and missed most of the class and now I'm facing a serious problem with this Java class. Anyone know where I can find tutor online for 1 on 1 question & answer. I'd really appreciate it. Lay out your difficulties here, a lot of people are decently good with Java and can probably give you some pointers.
|
On April 07 2013 05:12 phar wrote:Show nested quote +On April 07 2013 05:04 tuho12345 wrote: man I suck so bad at Java, I worked so hard for my 2 other jobs and missed most of the class and now I'm facing a serious problem with this Java class. Anyone know where I can find tutor online for 1 on 1 question & answer. I'd really appreciate it. Lay out your difficulties here, a lot of people are decently good with Java and can probably give you some pointers. ok so I'm an Business major with MIS concentration, so this guy recommend me to study Java and promise he'll help me to find an internship for the summer. I ate that up and reg this class. However I was so busy with my 2 jobs in the first half of the semester. That and having no computer science background knowledge really fuck me over. I'm decent with VB, that's why they let me in this class. So now I beside reading book, I don't have any idea how I can write an algorithm, how I can solve the problem. For example I have to write a loop that draw a polygon and a square. Now to the most difficult part of writing the drawing method. I don't know how or where to start.
|
On April 03 2013 17:07 CorsairHero wrote:Show nested quote +On April 03 2013 09:53 CecilSunkure wrote:On April 03 2013 09:15 CorsairHero wrote:man...double pointers  Anyone going for a C programming job should look them up. I keep hearing about this. Are you talking about pointers to a pointers in general, or the branch reduction trick? Just pointers in general. For some reason, I had always thought you could change the pointer itself when passing it in as a function parameter. Apparently a double pointer is needed to be passed in. I shouldn't be complaining though because the documentation is online. It was just something I didn't use in my classes or in practice at my internship.
Use a reference?
Edit: Nevermind, sorry. I didn't know that was C++ only... Well I learned something at least :p
|
On April 07 2013 05:33 tuho12345 wrote:Show nested quote +On April 07 2013 05:12 phar wrote:On April 07 2013 05:04 tuho12345 wrote: man I suck so bad at Java, I worked so hard for my 2 other jobs and missed most of the class and now I'm facing a serious problem with this Java class. Anyone know where I can find tutor online for 1 on 1 question & answer. I'd really appreciate it. Lay out your difficulties here, a lot of people are decently good with Java and can probably give you some pointers. ok so I'm an Business major with MIS concentration, so this guy recommend me to study Java and promise he'll help me to find an internship for the summer. I ate that up and reg this class. However I was so busy with my 2 jobs in the first half of the semester. That and having no computer science background knowledge really fuck me over. I'm decent with VB, that's why they let me in this class. So now I beside reading book, I don't have any idea how I can write an algorithm, how I can solve the problem. For example I have to write a loop that draw a polygon and a square. Now to the most difficult part of writing the drawing method. I don't know how or where to start. 
Okay, so that seems pretty basic and not exactly language exclusive, so what have you got written so far, and what are the requirements of what you want to do? Drawing shapes is pretty good practice.
|
So I've started to try to do some of the project Euler problems as a sort of trial by fire method of teaching myself to code. I did problems 1 and 2 easily and three with some difficulty. Four actually seems relatively easy; it's
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99.
Find the largest palindrome made from the product of two 3-digit numbers. I wrote some code in python to solve it but I keep getting an "invalid syntax" error. It's a short, simple program so I'd appreciate if somebody could just tell me what to fix. Admittedly, I'm very very shaky on syntax in general.
+ Show Spoiler + from time import sleep
A = 100 B = 100 palindromes = []
def palindrometest(n): If (len(n) == 5): If (n[0] == n[4]) and (n[1] == n [3]): palindromes.append(n) If (len (n) == 6): If (n[0] == n[5]) and (n[1] == n[4]) and (n[2] == n[3]): palindromes.append(n)
While (B < 1000): While (A < 1000): t = A * B number = str(t) palindrometest(number) A = A + 1 B = B + 1 A = 100
print max(palindromes)
sleep(15)
Don't worry about the sleep portion.
|
I would guess the issue is that you capitalized "if" and "while".
And imo it would be faster if you reverse everything, so you countdown from 1000 instead of up, the first palyndrome you find will be also the highest
|
Sigh... thanks. I messed up on the math but that was the error. I feel like a complete noob.
|
Are there any Linux kernel developers on TL?
|
Have played a bit with the linux kernel - was for embedded purposes though, but maybe I know something useful for you =)
|
Anyone have any advice for a freshman Computer Science major at university next year? I've been programming for a while now, but obviously haven't taken many college level computer science courses before(except for CS50, which is an very very very introductory course).
Are there any courses I should watch out for, things I should learn before going? Any advice would be helpful .
I will be attending Carnegie Mellon if that makes a difference – I assume that CMU courses will NOT be easy.
|
|
|
|