Content-Length: 279717 | pFad | http://github.com/madyx/musicg/commit/c632fce08d0f7b41fe2bd6a3d1ac2d9f3624132b

88 added clone() methods · madyx/musicg@c632fce · GitHub
Skip to content

Commit

Permalink
added clone() methods
Browse files Browse the repository at this point in the history
  • Loading branch information
fracpete committed Apr 10, 2018
1 parent 98c8438 commit c632fce
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/main/java/com/musicg/wave/Wave.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
*
* @author Jacquet Wong
*/
public class Wave implements Serializable{
public class Wave
implements Serializable, Cloneable{

private static final long serialVersionUID = 1L;
private WaveHeader waveHeader;
Expand Down Expand Up @@ -346,4 +347,14 @@ public float getLengthInSeconds() {
float second = (float) waveHeader.getSubChunk2Size() / waveHeader.getByteRate();
return second;
}

public Wave clone() {
Wave result = new Wave();
result.waveHeader = waveHeader.clone();
if (data != null)
result.data = data.clone();
if (fingerprint != null)
result.fingerprint = fingerprint.clone();
return result;
}
}
23 changes: 22 additions & 1 deletion src/main/java/com/musicg/wave/WaveHeader.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@

import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;

/**
* WAV File Specification
* https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
*
* @author Jacquet Wong
*/
public class WaveHeader {
public class WaveHeader
implements Serializable, Cloneable {

public static final String RIFF_HEADER = "RIFF";
public static final String WAVE_HEADER = "WAVE";
Expand Down Expand Up @@ -258,6 +260,25 @@ public void setSubChunk2Size(long subChunk2Size) {
this.subChunk2Size = subChunk2Size;
}

public WaveHeader clone() {
WaveHeader result = new WaveHeader();
result.valid = valid;
result.chunkId = chunkId;
result.chunkSize = chunkSize;
result.format = format;
result.subChunk1Id = subChunk1Id;
result.subChunk1Size = subChunk1Size;
result.audioFormat = audioFormat;
result.channels = channels;
result.sampleRate = sampleRate;
result.byteRate = byteRate;
result.blockAlign = blockAlign;
result.bitsPerSample = bitsPerSample;
result.subChunk2Id = subChunk2Id;
result.subChunk2Size = subChunk2Size;
return result;
}

public String toString() {

StringBuffer sb = new StringBuffer();
Expand Down

0 comments on commit c632fce

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/madyx/musicg/commit/c632fce08d0f7b41fe2bd6a3d1ac2d9f3624132b

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy