Skip to content

Instantly share code, notes, and snippets.

View HyCraftHD's full-sized avatar

Johannes Jäger HyCraftHD

View GitHub Profile
@HyCraftHD
HyCraftHD / Test.java
Last active December 23, 2019 11:36
Simultaneously recorde from two mics and play it back to one speaker in java
import javax.sound.sampled.*;
public class Test {
private static final AudioFormat FORMAT = new AudioFormat(48000, 16, 2, true, false);
private static final DataLine.Info MIC_INFO = new DataLine.Info(TargetDataLine.class, FORMAT);
private static final DataLine.Info SPEAKER_INFO = new DataLine.Info(SourceDataLine.class, FORMAT);
public static void main(String[] args) throws LineUnavailableException {
final TargetDataLine micro1 = findMicrophoneOrUseDefault("name");
@HyCraftHD
HyCraftHD / EndianConverter.java
Created December 11, 2019 16:17
Endian converter java
public static void endianConverter(byte[] buffer, int length) {
if (buffer.length % length != 0 || length % 2 != 0) {
throw new IllegalStateException();
}
for (int index = 0; index < buffer.length; index += length) {
for (int endianIndex = 0; endianIndex < length / 2; endianIndex++) {
final byte temp = buffer[index + endianIndex];
buffer[index + endianIndex] = buffer[index + length - endianIndex - 1];
buffer[index + length - endianIndex - 1] = temp;
}
@HyCraftHD
HyCraftHD / VoiceChat.java
Created December 3, 2019 22:29
Basic UDP audio transmission (Audio data is encoded with opus)
package test.voicechat;
import java.net.*;
import javax.sound.sampled.*;
import org.concentus.*;
/**
* Use of native java opus port (https://github.com/lostromb/concentus) used in here. Every other opus java wrapper shoud work too.
@HyCraftHD
HyCraftHD / VoiceChat.java
Created December 3, 2019 22:13
Basic UDP audio transmission (ATTENTION, The audio is raw and will not be encoded)
package test.voicechat;
import java.net.*;
import javax.sound.sampled.*;
public class VoiceChat {
private final static String HOST = "udp.echoserver.example";
This file has been truncated, but you can view the full file.
2003:cf:f2f:c70:e532:33d9:285c:77f7 => muc11s17 : router: "pf01.muc11" next_hop_address: "2003:0:1807:4::1" (2003:cf:800::/37)
Debug Info:
o-AFVadmd8Kmj0XGfdJlgHNg2lVu1Wj2TAyq_YFCtYUm4xUkMfPVJylxD7KPFpKP8gNDP-STJUG5yEv0
DUOLlYa5dCIGGol5iPm6qDOQxDqjuopvNUirH0OrLvd2YCdFPn7VY65sX17GCF6YJohpwgtjG39Di1EM
Tp4ir6tG9LB2PKNGKwhV8PcwHaed3RLcz5q0H3IvaiSi9V5j6sKoMtDFsuAFZGxZwmi9cBnlyirGX0Os
kLWPKHF7WbfvZved_fTWYgXJpl30uWQGbFa67F5R3PNa-VH0lSQbDGzUBT16v1PeeIBsU-1Wu_2u_962
GdGG19BHQ5ccy62ne3PdAAzdGx_xGEdo0UORa1j2K4kTvNPsxxRHbUWEb7HLSxkKf_WQHQFfj3XyOKMF
BTw4dkXfMfNO0-Y4AZlAKXoPCv-v93Ulv1yCrqVRMb0A59ClRW-MWMhdUNrOevIiayQvJqS_k78Y4-Cy
ABQvkUt1a_P7mT1jhEc35fgiKA2E5i16rIm01ILPP2m2JJWkqmPafl6DvcceWT3Uw0YpHrJigm_Tho70
@HyCraftHD
HyCraftHD / GsonConfig.java
Last active May 24, 2019 08:58
Easy Json configuration with Gson
package info.u_team.music_player.musicplayer;
import java.io.*;
import java.nio.file.*;
import org.apache.logging.log4j.*;
import com.google.gson.*;
public class GsonConfig {
@HyCraftHD
HyCraftHD / Nginx.conf
Last active July 3, 2018 01:22
Simple Mavenserver
#Config for repo
server {
include snippets/base.cfg; # Basic SSL and listening handling
server_name repo.domain.name;
root /var/www/repo/;
autoindex on;
location / {
@HyCraftHD
HyCraftHD / ScrollingTextRender.java
Created April 21, 2018 17:55
Basic scrolling text render with some settings and correct scaling
package info.u_team.music_player.impl.event;
import java.math.BigDecimal;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.*;
public class ScrollingTextRender {
@HyCraftHD
HyCraftHD / build.gradle
Created April 13, 2018 18:08
Shade dependecies with reobf from minecraft forge (not working for unobfuscated files)
buildscript {
repositories {
jcenter()
maven { url = "http://files.minecraftforge.net/maven" }
maven { url = "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT"
classpath "gradle.plugin.com.matthewprenger:CurseGradle:1.0.9"
}
@HyCraftHD
HyCraftHD / test.java
Created April 5, 2018 14:01
Basic Ivy code to download maven dependecies
package test;
import java.io.File;
import org.apache.ivy.Ivy;
import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.report.ResolveReport;