Skip to content

Commit

Permalink
Implement inhibbitor cross fading
Browse files Browse the repository at this point in the history
  • Loading branch information
Mindgamesnl committed May 31, 2024
1 parent b185ac1 commit 1b6b0ee
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 25 deletions.
2 changes: 1 addition & 1 deletion client/public/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"buildMajor":1,"buildMinor":125,"buildRevision":240,"buildTag":"dev","buildDate":"Sun May 05 2024","build":"1.125.240 dev"}
{"buildMajor":1,"buildMinor":125,"buildRevision":241,"buildTag":"dev","buildDate":"Fri May 31 2024","build":"1.125.241 dev"}
1 change: 1 addition & 0 deletions client/src/client/services/media/MediaManager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const MediaManager = new class IMediaManager {
const channel = chls[i];
if (all) {
channel.fadeChannel(0, time, () => {
console.log('callback reached');

Check warning on line 89 in client/src/client/services/media/MediaManager.jsx

View workflow job for this annotation

GitHub Actions / build (20.*)

Unexpected console statement
this.mixer.removeChannel(channel);
});
matchedAndStopped = channel;
Expand Down
21 changes: 17 additions & 4 deletions client/src/client/services/media/objects/Channel.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
import { getGlobalState } from '../../../../state/store';
import { debugLog } from '../../debugging/DebugService';

export class Channel {
constructor(channelName) {
constructor(channelName, originalVolume = 100) {
this.channelName = channelName;
this.channelVolume = 100;
this.channelVolume = originalVolume;
this.originalVolume = originalVolume;
this.sounds = [];
this.mixer = null;
this.targetAfterFade = 0;
this.isFading = false;
this.fadeTimer = [];
this.tags = new Map();
this.trackable = false;
this.prefferedFadeTime = 2;
}

getOriginalVolume() {
return this.originalVolume;
}

setPrefferedFadeTime(fadeTime) {
console.log('Setting preffered fade time to', fadeTime);

Check warning on line 23 in client/src/client/services/media/objects/Channel.jsx

View workflow job for this annotation

GitHub Actions / build (20.*)

Unexpected console statement
this.prefferedFadeTime = fadeTime;
}

getPrefferedFadeTime() {
return this.prefferedFadeTime || 2;
}

setTag(name) {
Expand Down Expand Up @@ -65,7 +79,6 @@ export class Channel {

// is the fade time set to 0? then just set the volume, do callback and return
if (time === 0) {
debugLog('Fading channel', this.channelName, 'to', targetVolume, 'instantly');
this.setChannelVolume(targetVolume);
extraCallback();
return;
Expand Down
20 changes: 16 additions & 4 deletions client/src/client/services/media/objects/Mixer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,22 @@ export class Mixer {
}
});

if (score >= 1) {
channel.setMediaMuted(true);
} else {
channel.setMediaMuted(false);
const fade = channel.getPrefferedFadeTime() > 5;

if (score >= 1 && !channel.mutedByScore) {
channel.mutedByScore = true;
if (fade) {
channel.fadeChannel(0, channel.getPrefferedFadeTime());
} else {
channel.setChannelVolume(0);
}
} else if (score === 0 && channel.mutedByScore) {
channel.mutedByScore = false;
if (fade) {
channel.fadeChannel(channel.getOriginalVolume(), channel.getPrefferedFadeTime());
} else {
channel.setChannelVolume(channel.getOriginalVolume());
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ export async function handleCreateMedia(data) {
MediaManager.destroySounds(id, false, true);

// register with metadata
const createdChannel = new Channel(id);
const createdChannel = new Channel(id, volume);
createdChannel.trackable = true;
createdChannel.setPrefferedFadeTime(fadeTime);
const createdMedia = new Sound();

createdChannel.addSound(createdMedia);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { MediaManager } from '../../media/MediaManager';

export function handleDestroyMedia(data) {
console.log(data);

Check warning on line 4 in client/src/client/services/socket/handlers/HandleDestroyMedia.jsx

View workflow job for this annotation

GitHub Actions / build (20.*)

Unexpected console statement
const succeeded = MediaManager.destroySounds(data.soundId, data.all, false, data.fadeTime);
if (!succeeded) {
// eslint-disable-next-line no-console
Expand Down
2 changes: 1 addition & 1 deletion client/src/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"buildMajor":1,"buildMinor":125,"buildRevision":240,"buildTag":"dev","buildDate":"Sun May 05 2024","build":"1.125.240 dev"}
{"buildMajor":1,"buildMinor":125,"buildRevision":241,"buildTag":"dev","buildDate":"Fri May 31 2024","build":"1.125.241 dev"}
8 changes: 4 additions & 4 deletions dev-resources/spawn-test-spigot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ cp dev-resources/ops.json test-server-spigot/

cd test-server-spigot
echo "Cleaning server..."
if [ ! -f ./spigot-1.20.2.jar ]; then
wget https://download.getbukkit.org/spigot/spigot-1.20.2.jar
if [ ! -f ./spigot-1.20.4.jar ]; then
wget https://download.getbukkit.org/spigot/spigot-1.20.4.jar
echo "eula=true" > eula.txt
chmod +x spigot-1.20.2.jar
chmod +x spigot-1.20.4.jar
fi

#export OA_ENVIRONMENT="DEVELOPMENT"
Expand All @@ -29,4 +29,4 @@ echo "Starting server.."
rm world/session.lock
rm world_the_end/session.lock
rm world_nether/session.lock
java -Xms3G -Xmx3G -DIReallyKnowWhatIAmDoingISwear -jar paper-1.20.6-49.jar nogui
java -Xms3G -Xmx3G -DIReallyKnowWhatIAmDoingISwear -jar spigot-1.20.4.jar nogui
6 changes: 0 additions & 6 deletions modules/vistas-server/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,6 @@
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>hamcrest-core</artifactId>
<groupId>org.hamcrest</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<properties>
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/bash/data.bin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BUILD_NUM="1433"
BUILD_NUM="1438"
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public Media getMediaForWorld(WorldRegionManager worldRegionManager) {
if (loop == null) loop = true;
Media media = worldRegionManager.getRegionMedia(source, volume, fadeTimeMs, loop);
media.setDoPickup(this.doSync);
media.setFadeTime(fadeTimeMs);
return media;
}

Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/resources/data.bin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BUILD_NUM="1433"
BUILD_NUM="1438"
4 changes: 2 additions & 2 deletions plugin/src/main/resources/openaudiomc-build.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
BUILD_VERSION="1433"
BUILD_COMMIT="e9dd7b36b9ce027c21f01124492be0a47231f1cb"
BUILD_VERSION="1438"
BUILD_COMMIT="b185ac1858bdbe73f0106928153783356d59ef1b"
BUILD_AUTHOR="Mats"

0 comments on commit 1b6b0ee

Please sign in to comment.