Skip to content

Commit

Permalink
fix: Midi creation and removed hidden recording idea
Browse files Browse the repository at this point in the history
  • Loading branch information
dariodumlijan committed Mar 19, 2024
1 parent 32d0bb9 commit 180714e
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 178 deletions.
19 changes: 0 additions & 19 deletions app/assets/icons/Recordings.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions app/components/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import AdmobBanner from './elements/misc/AdmobBanner';
import RewardsCountdown from './elements/misc/RewardsCountdown';
import Guide from './screens/Guide';
import Home from './screens/Home';
import Library from './screens/Library';
import Loading from './screens/Loading';
import Rewarded from './screens/Rewarded';
import Settings from './screens/Settings';
Expand Down Expand Up @@ -65,7 +64,6 @@ function Body() {
<Routes>
<Route index element={<Home />} />
<Route path="/settings" element={<Settings />} />
<Route path="/library" element={<Library />} />
<Route path="/guide" element={(<Guide />)} />
<Route path="/state-tree" element={<StateTree />} />
<Route path="/rewarded/:section" element={<Rewarded />} />
Expand Down
96 changes: 0 additions & 96 deletions app/components/blocks/bottom/Bottom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,91 +85,6 @@ function Bottom() {
dispatch(beatActions.resetBeat());
};

// const handleRecording = () => {};

/* Recording Functions - START */
/*
const startRec = async () => {
let findBeat = false;
for (let i in beats.hihat) {
if (
beats.hihat[i].checked === true ||
beats.snare[i].checked === true ||
beats.kick[i].checked === true
) {
findBeat = true;
break;
}
}
let status = (await Audio.getPermissionsAsync()).granted;
if (status === true && isPlaying === false && findBeat === true) {
try {
await Audio.setAudioModeAsync({
allowsRecordingIOS: true,
playsInSilentModeIOS: true,
staysActiveInBackground: false,
shouldDuckAndroid: false,
playThroughEarpieceAndroid: false,
interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_DO_NOT_MIX,
interruptionModeAndroid:
Audio.INTERRUPTION_MODE_ANDROID_DO_NOT_MIX,
});
await recording.prepareToRecordAsync(RecordingOptions);
await recording.startAsync();
start();
isRecording = true;
setRecordingStatus(isRecording);
} catch (err) {
console.error(err);
}
} else if (status === true && isPlaying === true && findBeat === true) {
try {
await Audio.setAudioModeAsync({
allowsRecordingIOS: true,
playsInSilentModeIOS: true,
staysActiveInBackground: false,
shouldDuckAndroid: false,
playThroughEarpieceAndroid: true,
interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_DO_NOT_MIX,
interruptionModeAndroid:
Audio.INTERRUPTION_MODE_ANDROID_DO_NOT_MIX,
});
await recording.prepareToRecordAsync(RecordingOptions);
await recording.startAsync();
isRecording = true;
setRecordingStatus(isRecording);
} catch (err) {
console.error(err);
}
} else if (status === true && isPlaying === false && findBeat === false) {
alertDelay();
} else {
await Audio.requestPermissionsAsync();
}
};
const stopRec = async () => {
pause();
await recording.stopAndUnloadAsync();
setRecording(new Audio.Recording());
const uri = recording.getURI();
console.log(uri);
// Current Save Folder URL: /Users/dariodumlijan/Library/Developer/CoreSimulator/Devices/B54A7218-4990-45B7-925F-BC578F42FB29/data/Containers/Data/Application/13C70B38-FE6B-4F46-A0C0-CC95AE195051/Library/Caches/ExponentExperienceData/%40ddario%2FRitmo
isRecording = false;
setRecordingStatus(isRecording);
};
*/
/* Recording Functions - END */

return (
<View style={bottomStyle.wrapper}>
<View style={bottomStyle.wrapperBG}>
Expand Down Expand Up @@ -225,17 +140,6 @@ function Bottom() {
>
<Text style={bottomStyle.btnPrimaryText}>{t('bottom.actions.reset')}</Text>
</TouchableHighlight>
{/* <TouchableHighlight
underlayColor={colors.grayBlue}
style={[bottomStyle.btnPrimary, bottomStyle.btnRecording]}
onPress={handleRecording}
>
<View
style={[bottomStyle.iconRecording, {
backgroundColor: global.ui.isRecording ? colors.white : colors.red,
}]}
/>
</TouchableHighlight> */}
</View>
</View>
</View>
Expand Down
25 changes: 13 additions & 12 deletions app/components/blocks/navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { isEqual, map } from 'lodash';
import Exit from '../../../assets/icons/Exit';
import Export from '../../../assets/icons/Export';
import Guide from '../../../assets/icons/Guide';
import Recordings from '../../../assets/icons/Recordings';
import Settings from '../../../assets/icons/Settings';
import StateTree from '../../../assets/icons/StateTree';
import useLocale from '../../../locales';
Expand Down Expand Up @@ -44,10 +43,10 @@ function Navigation() {
visible: true,
},
{
path: 'library',
label: t('navigation.library'),
icon: <Recordings style={navigationStyle.icon} />,
visible: false,
path: 'export',
label: t('navigation.export'),
icon: <Export style={navigationStyle.icon} />,
visible: true,
},
{
path: 'guide',
Expand Down Expand Up @@ -131,7 +130,7 @@ function Navigation() {
<View style={navigationStyle.linksWrapper}>
{map(links, (link) => (
<React.Fragment key={link.path}>
{link.visible && (
{link.visible && link.path !== 'export' && (
<Link
style={navigationStyle.link}
underlayColor={colors.transparent}
Expand All @@ -144,14 +143,16 @@ function Navigation() {
</View>
</Link>
)}
{link.visible && link.path === 'export' && (
<TouchableOpacity style={navigationStyle.link} activeOpacity={0.6} onPress={openMidiModal}>
<View style={navigationStyle.button}>
<Text style={navigationStyle.label}>{t('navigation.export')}</Text>
<Export style={navigationStyle.icon} />
</View>
</TouchableOpacity>
)}
</React.Fragment>
))}
<TouchableOpacity style={navigationStyle.link} activeOpacity={0.6} onPress={openMidiModal}>
<View style={navigationStyle.button}>
<Text style={navigationStyle.label}>{t('navigation.export')}</Text>
<Export style={navigationStyle.icon} />
</View>
</TouchableOpacity>
</View>
</View>
</>
Expand Down
19 changes: 0 additions & 19 deletions app/components/screens/Library.tsx

This file was deleted.

3 changes: 1 addition & 2 deletions app/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
"title": "Redefine Beatmaking",
"alert": "Nothing to export!",
"settings": "Settings",
"library": "Library",
"guide": "Guide",
"state_tree": "State Tree",
"export": "Export MIDI"
"export": "Export"
},
"bottom": {
"preset": {
Expand Down
4 changes: 4 additions & 0 deletions app/midi/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { Buffer } from 'buffer';
import RNFS from 'react-native-fs';
import Share from 'react-native-share';
import { filter, forEach, times } from 'lodash';
import MidiWriter from 'midi-writer-js';
import type { Beat, Beats } from '../sound/beats';
import type { TimeSignature } from '../store/globalStore';

// @ts-ignore
window.Buffer = Buffer; // HACK to fix midi-writer-js: Buffer is not defined

type MidiNote = 'KSH' | 'KS' | 'KH' | 'SH' | 'K' | 'S' | 'H';
type Note = MidiNote | 'R';
type MidiLayout = MidiNote[];
Expand Down
7 changes: 3 additions & 4 deletions app/store/globalStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export type TimeSignature = {
export type UI = {
fileUri?: string,
isPlaying: boolean,
isRecording: boolean,
navigationOpen?: boolean,
personalisedAds?: boolean,
selectedReward?: Sample | null,
Expand Down Expand Up @@ -361,7 +360,6 @@ const resetBeat = (state: State): State => {
return merge({}, state, {
ui: {
isPlaying: false,
isRecording: false,
useBPM: 100,
useTimeSig: {
hihat: timeSig.value,
Expand Down Expand Up @@ -401,7 +399,6 @@ const loadPreset = (state: State, preset: Preset): State => ({
ui: {
...state.ui,
isPlaying: false,
isRecording: false,
useBPM: preset.useBPM,
useTimeSig: preset.useTimeSig,
},
Expand Down Expand Up @@ -503,9 +500,11 @@ export const reducer = (state: any, action: ReduxAction) => {
return merge({}, state, { ui: { isPlaying: false } });

case GlobalTypes.GB_EXPORT_MIDI_FULFILLED:
case GlobalTypes.GB_EXPORT_MIDI_REJECTED:
return exportMIDI(state, action.payload);

case GlobalTypes.GB_EXPORT_MIDI_REJECTED:
return state;

case GlobalTypes.GB_DELETE_MIDI_FILE:
return omit(state, 'ui.fileUri');

Expand Down
1 change: 0 additions & 1 deletion app/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const initialState = {
ui: {
showAds: true,
isPlaying: false,
isRecording: false,
useBPM: 100,
useSample: sample,
useTimeSig: {
Expand Down
10 changes: 0 additions & 10 deletions app/styles/bottom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,6 @@ const bottomStyle = StyleSheet.create({
fontSize: isTablet ? 20 : 16,
textAlign: 'center',
},
btnRecording: {
borderRadius: 10,
paddingHorizontal: 10,
paddingVertical: 10,
},
iconRecording: {
aspectRatio: 1 / 1,
borderRadius: 10,
width: 16,
},
});

export default bottomStyle;
14 changes: 1 addition & 13 deletions app/utils/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,12 @@ export const useReview = () => {
return handleReview;
};

export type LocationInfo = {
current: string,
isHome: boolean,
isRewarded: boolean,
isSettings: boolean,
isGuide: boolean,
isLibrary: boolean,
isStateTree: boolean,
};

export const useLocationInfo = (): LocationInfo => {
export const useLocationInfo = () => {
const location = useLocation();
const isHome = location.pathname === '/';
const isRewarded = location.pathname.includes('/rewarded');
const isSettings = location.pathname === '/settings';
const isGuide = location.pathname === '/guide';
const isLibrary = location.pathname === '/library';
const isStateTree = location.pathname === '/state-tree';

return {
Expand All @@ -113,7 +102,6 @@ export const useLocationInfo = (): LocationInfo => {
isRewarded,
isSettings,
isGuide,
isLibrary,
isStateTree,
};
};
Expand Down

0 comments on commit 180714e

Please sign in to comment.