Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

This is version 1.2, available at http://code.google.com/p/wii-metron…

  • Loading branch information...
commit e52bdf349ba40b0c7d337fa84cc95321920e44ae 1 parent b7f6009
@westy92 authored
View
159 Makefile
@@ -0,0 +1,159 @@
+#---------------------------------------------------------------------------------
+# Clear the implicit built in rules
+#---------------------------------------------------------------------------------
+.SUFFIXES:
+#---------------------------------------------------------------------------------
+ifeq ($(strip $(DEVKITPPC)),)
+$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
+endif
+
+include $(DEVKITPPC)/wii_rules
+
+#---------------------------------------------------------------------------------
+# TARGET is the name of the output
+# BUILD is the directory where object files & intermediate files will be placed
+# SOURCES is a list of directories containing source code
+# INCLUDES is a list of directories containing extra header files
+#---------------------------------------------------------------------------------
+TARGET := boot
+BUILD := build
+SOURCES := source
+DATA := data
+INCLUDES :=
+
+#---------------------------------------------------------------------------------
+# options for code generation
+#---------------------------------------------------------------------------------
+
+CFLAGS = -g -O2 -mrvl -Wall $(MACHDEP) $(INCLUDE) -I$(DEVKITPPC)/local/include
+CXXFLAGS = $(CFLAGS)
+
+LDFLAGS = -g $(MACHDEP) -mrvl -Wl,-Map,$(notdir $@).map
+
+#---------------------------------------------------------------------------------
+# any extra libraries we wish to link with the project
+#---------------------------------------------------------------------------------
+LIBS := -lz -lwiiuse -lmad -lbte -lfat -logc -lm
+
+#---------------------------------------------------------------------------------
+# list of directories containing libraries, this must be the top level containing
+# include and lib
+#---------------------------------------------------------------------------------
+LIBDIRS :=
+
+#---------------------------------------------------------------------------------
+# no real need to edit anything past this point unless you need to add additional
+# rules for different file extensions
+#---------------------------------------------------------------------------------
+ifneq ($(BUILD),$(notdir $(CURDIR)))
+#---------------------------------------------------------------------------------
+
+export OUTPUT := $(CURDIR)/$(TARGET)
+
+export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
+ $(foreach dir,$(DATA),$(CURDIR)/$(dir))
+
+export DEPSDIR := $(CURDIR)/$(BUILD)
+
+#---------------------------------------------------------------------------------
+# automatically build a list of object files for our project
+#---------------------------------------------------------------------------------
+CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
+CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
+sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
+BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
+
+#---------------------------------------------------------------------------------
+# use CXX for linking C++ projects, CC for standard C
+#---------------------------------------------------------------------------------
+ifeq ($(strip $(CPPFILES)),)
+ export LD := $(CC)
+else
+ export LD := $(CXX)
+endif
+
+export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
+ $(sFILES:.s=.o) $(SFILES:.S=.o)
+
+#---------------------------------------------------------------------------------
+# build a list of include paths
+#---------------------------------------------------------------------------------
+export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
+ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
+ -I$(CURDIR)/$(BUILD) \
+ -I$(LIBOGC_INC)
+
+#---------------------------------------------------------------------------------
+# build a list of library paths
+#---------------------------------------------------------------------------------
+export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
+ -L$(LIBOGC_LIB) -L$(DEVKITPPC)/local/lib
+
+export OUTPUT := $(CURDIR)/$(TARGET)
+.PHONY: $(BUILD) clean
+
+#---------------------------------------------------------------------------------
+$(BUILD):
+ @[ -d $@ ] || mkdir -p $@
+ @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
+
+#---------------------------------------------------------------------------------
+clean:
+ @echo clean ...
+ @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
+
+#---------------------------------------------------------------------------------
+run:
+ psoload $(TARGET).dol
+
+#---------------------------------------------------------------------------------
+reload:
+ psoload -r $(TARGET).dol
+
+
+#---------------------------------------------------------------------------------
+else
+
+DEPENDS := $(OFILES:.o=.d)
+
+#---------------------------------------------------------------------------------
+# main targets
+#---------------------------------------------------------------------------------
+$(OUTPUT).dol: $(OUTPUT).elf
+$(OUTPUT).elf: $(OFILES)
+
+#---------------------------------------------------------------------------------
+# This rule links in binary data with the .jpg extension
+#---------------------------------------------------------------------------------
+%.jpg.o : %.jpg
+#---------------------------------------------------------------------------------
+ @echo $(notdir $<)
+ $(bin2o)
+
+-include $(DEPENDS)
+
+#---------------------------------------------------------------------------------
+# This rule links in binary data with the .png extension
+#---------------------------------------------------------------------------------
+%.png.o : %.png
+#---------------------------------------------------------------------------------
+ @echo $(notdir $<)
+ $(bin2o)
+
+-include $(DEPENDS)
+
+#---------------------------------------------------------------------------------
+# This rule links in binary data with the .mp3 extension
+#---------------------------------------------------------------------------------
+%.mp3.o : %.mp3
+#---------------------------------------------------------------------------------
+ @echo $(notdir $<)
+ $(bin2o)
+
+-include $(DEPENDS)
+
+#---------------------------------------------------------------------------------
+endif
+#---------------------------------------------------------------------------------
View
1  clean.bat
@@ -0,0 +1 @@
+make clean
View
5 compile.bat
@@ -0,0 +1,5 @@
+:loop
+make clean
+make
+pause
+goto loop
View
BIN  data/strongbeat.mp3
Binary file not shown
View
BIN  icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
9 meta.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ <app version="1">
+ <name>Metronome</name>
+ <coder>Westy92</coder>
+ <version>1.2</version>
+ <release_date>20090101</release_date>
+ <short_description>A Metronome for the Wii</short_description>
+ <long_description>This is the first metronome ever coded for the Nintendo Wii. Using this application, you can keep a steady tempo while practicing an instrument.</long_description>
+ </app>
View
128 source/metronome.cpp
@@ -0,0 +1,128 @@
+//Author: Westy92
+//Title: Metronome.cpp
+//Date: 12/31/2008
+//Version: 1.2
+//Description: Homebrew Metronome For The Nintendo Wii.
+#include <iostream>
+#include <gccore.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <wiiuse/wpad.h>
+#include <mp3player.h>
+#include "strongbeat_mp3.h" //MP3 File
+
+using namespace std; //DECLARE NAMESPACE
+
+// GLOBAL VARIABLES
+int bpm;
+
+// SETS UP THE WII'S VIDEO HARDWARE
+void initVideo()
+{
+static void *xfb = NULL;
+static GXRModeObj *rmode = NULL;
+
+ VIDEO_Init();
+ rmode = VIDEO_GetPreferredMode(NULL);
+ xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
+ console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
+ VIDEO_Configure(rmode);
+ VIDEO_SetNextFramebuffer(xfb);
+ VIDEO_SetBlack(FALSE);
+ VIDEO_Flush();
+ VIDEO_WaitVSync();
+
+ if(rmode->viTVMode&VI_NON_INTERLACE)
+ VIDEO_WaitVSync();
+}
+
+void returnToLoader()
+{
+ // STOP MP3 PLAYING IF NECCESSARY
+ if (MP3Player_IsPlaying())
+ MP3Player_Stop();
+
+ cout<<"\n\n\n Returning to loader...";
+
+ // EXIT REPORTING 0 ERRORS
+ exit(0);
+}
+
+// FUNCTION THAT CONSTANTLY PLAY'S MP3 (BEEP) THEN PAUSES THEN BEEPS THEN PAUSES ETC
+static void *beepPauseBeepPause(void *arg)
+{
+int ms;
+
+ while (1)
+ {
+ if (!MP3Player_IsPlaying())
+ MP3Player_PlayBuffer(strongbeat_mp3, strongbeat_mp3_size, NULL);
+
+ ms = (60000000.0 / bpm);
+ usleep(ms);
+ }
+}
+
+int main(int argc, char **argv)
+{
+int ms;
+char tempo_marking[15];
+lwp_t MP3thread;
+
+ // INIT VIDEO
+ initVideo();
+
+ // SETUP WIIMOTE
+ WPAD_Init();
+ WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
+
+ // INIT MUSIC
+ bpm = 120;
+ MP3Player_Init();
+
+ // AND START THE MP3 PLAYING THREAD (beepPauseBeepPause)
+ LWP_CreateThread(&MP3thread, beepPauseBeepPause, NULL, NULL, 0, 80);
+
+ while (1)
+ {
+ WPAD_ScanPads();
+ //GET INPUT TO CHANGE BPM
+ if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME)
+ returnToLoader();
+ if (WPAD_ButtonsDown(0) & WIIMOTE_BUTTON_LEFT)
+ bpm = bpm - 1;
+ if (WPAD_ButtonsDown(0) & WIIMOTE_BUTTON_RIGHT)
+ bpm = bpm + 1;
+ if (WPAD_ButtonsDown(0) & WIIMOTE_BUTTON_UP)
+ bpm = bpm + 10;
+ if (WPAD_ButtonsDown(0) & WIIMOTE_BUTTON_DOWN)
+ bpm = bpm - 10;
+ if (WPAD_ButtonsDown(0) & WIIMOTE_BUTTON_ONE)
+ bpm = 250;
+ if (WPAD_ButtonsDown(0) & WIIMOTE_BUTTON_TWO)
+ bpm = 30;
+ //IF GREATER THAN MAXIMUM OR LESS THAN MINIMUM, SET TO MAX OR MINIMUM
+ if (bpm >= 250)
+ bpm = 250;
+ if (bpm <= 30)
+ bpm = 30;
+ //SET TEMPO MARKINGS
+ if (bpm <= 60) strcpy (tempo_marking, "Largo");
+ if (bpm >= 61 && bpm <= 66) strcpy (tempo_marking, "Larghetto");
+ if (bpm >= 67 && bpm <= 76) strcpy (tempo_marking, "Adagio");
+ if (bpm >= 77 && bpm <= 108) strcpy (tempo_marking, "Andante");
+ if (bpm >= 109 && bpm <= 120) strcpy (tempo_marking, "Moderato");
+ if (bpm >= 121 && bpm <= 168) strcpy (tempo_marking, "Allegro");
+ if (bpm >= 169 && bpm <= 200) strcpy (tempo_marking, "Presto");
+ if (bpm >= 201) strcpy (tempo_marking, "Prestissimo");
+ // PRINT OUT THE CURRENT BPM
+ ms = (60000000.0/bpm);
+ cout<<"\x1b[2J\x1b[2;0H";
+ cout<<"\n\n\n BPM = "<<" "<<bpm;
+ cout<<"\n\n\n 1 beat every "<<(ms / 1000)<<" milliseconds!" ;
+ cout<<"\n\n\n The tempo marking is "<<tempo_marking;
+
+ VIDEO_WaitVSync();
+ }
+ return 0;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.