Skip to content

Commit

Permalink
Added demo to solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Siaranite committed Apr 14, 2018
1 parent ab9ebc0 commit 1c4a40b
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 133 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2037
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleBeepDemo", "ConsoleBeepDemo\ConsoleBeepDemo.csproj", "{0AD02943-D563-43E4-A41F-D4FC1870C42A}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeepDemo", "BeepDemo.csproj", "{0AD02943-D563-43E4-A41F-D4FC1870C42A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
127 changes: 127 additions & 0 deletions Demos/BeepDemo/Kernel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
using System;
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;
using System.Threading;

namespace BeepDemo
{
public class Kernel: Sys.Kernel
{
protected override void BeforeRun()
{
Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back.");
}
protected override void Run()
{
Console.WriteLine("Run 'Mary Had a Little Lamb'? ");
string ans = Console.ReadLine();
if (ans.ToLower() == "y" || ans.ToLower() == "yes")
{
BeepTest.Main();
}
else
{
Console.WriteLine("Default beep:");
Console.Beep();
// Does the follwing: Console.Beep((int)Sys.Notes.Default (800 hertz), (int)Sys.Durations.Default (200 milliseconds) );
}
}
}
class BeepTest
{
public static void Main()
{
// Declare the first few notes of the song, "Mary Had A Little Lamb".
Note[] Mary =
{
new Note(Tone.B, Duration.QUARTER),
new Note(Tone.A, Duration.QUARTER),
new Note(Tone.GbelowC, Duration.QUARTER),
new Note(Tone.A, Duration.QUARTER),
new Note(Tone.B, Duration.QUARTER),
new Note(Tone.B, Duration.QUARTER),
new Note(Tone.B, Duration.HALF),
new Note(Tone.A, Duration.QUARTER),
new Note(Tone.A, Duration.QUARTER),
new Note(Tone.A, Duration.HALF),
new Note(Tone.B, Duration.QUARTER),
new Note(Tone.D, Duration.QUARTER),
new Note(Tone.D, Duration.HALF)
};
// Play the song
Play(Mary);
}

// Play the notes in a song.
protected static void Play(Note[] tune)
{
foreach (Note n in tune)
{
if (n.NoteTone == Tone.REST)
{
Thread.Sleep((int)n.NoteDuration);
}
else
{
Console.Beep((int)n.NoteTone, (int)n.NoteDuration);
}
}
}

// Define the frequencies of notes in an octave, as well as
// silence (rest).
protected enum Tone
{
REST = 0,
GbelowC = 196,
A = 220,
Asharp = 233,
B = 247,
C = 262,
Csharp = 277,
D = 294,
Dsharp = 311,
E = 330,
F = 349,
Fsharp = 370,
G = 392,
Gsharp = 415,
}

// Define the duration of a note in units of milliseconds.
protected enum Duration
{
WHOLE = 1600,
HALF = WHOLE / 2,
QUARTER = HALF / 2,
EIGHTH = QUARTER / 2,
SIXTEENTH = EIGHTH / 2,
}

// Define a note as a frequency (tone) and the amount of
// time (duration) the note plays.
protected struct Note
{
Tone toneVal;
Duration durVal;

// Define a constructor to create a specific note.
public Note(Tone frequency, Duration time)
{
toneVal = frequency;
durVal = time;
}

// Define properties to return the note's tone and duration.
public Tone NoteTone { get { return toneVal; } }
public Duration NoteDuration { get { return durVal; } }
}
}
/*
This example produces the following results:
This example plays the first few notes of "Mary Had A Little Lamb"
through the computer PC Speaker.
*/
}
32 changes: 0 additions & 32 deletions Demos/ConsoleBeepDemo/ConsoleBeepDemo/Kernel.cs

This file was deleted.

100 changes: 0 additions & 100 deletions Demos/ConsoleBeepDemo/ConsoleBeepDemo/Test.cs

This file was deleted.

14 changes: 14 additions & 0 deletions Kernel.sln
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spruce", "..\XSharp\source\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XSharp.x86", "..\XSharp\source\XSharp.x86\XSharp.x86.csproj", "{7370A62F-12DA-4181-BE3B-009D0926CA7E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BeepDemo", "BeepDemo", "{83BA8293-9BC0-496E-A9D4-7F8365BEEFCE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeepDemo", "Demos\BeepDemo\BeepDemo.csproj", "{5EF63907-CB93-4FA0-BA9C-B73EC7001365}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -335,6 +339,14 @@ Global
{7370A62F-12DA-4181-BE3B-009D0926CA7E}.Release|Any CPU.Build.0 = Release|Any CPU
{7370A62F-12DA-4181-BE3B-009D0926CA7E}.Release|x86.ActiveCfg = Release|Any CPU
{7370A62F-12DA-4181-BE3B-009D0926CA7E}.Release|x86.Build.0 = Release|Any CPU
{5EF63907-CB93-4FA0-BA9C-B73EC7001365}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5EF63907-CB93-4FA0-BA9C-B73EC7001365}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5EF63907-CB93-4FA0-BA9C-B73EC7001365}.Debug|x86.ActiveCfg = Debug|Any CPU
{5EF63907-CB93-4FA0-BA9C-B73EC7001365}.Debug|x86.Build.0 = Debug|Any CPU
{5EF63907-CB93-4FA0-BA9C-B73EC7001365}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5EF63907-CB93-4FA0-BA9C-B73EC7001365}.Release|Any CPU.Build.0 = Release|Any CPU
{5EF63907-CB93-4FA0-BA9C-B73EC7001365}.Release|x86.ActiveCfg = Release|Any CPU
{5EF63907-CB93-4FA0-BA9C-B73EC7001365}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -380,6 +392,8 @@ Global
{E35E0DBF-555F-4D38-8F28-ACDFA9DC97BD} = {5FF9BF2A-5162-4F12-82B6-1693AD776636}
{0812DD0A-4CEE-4376-B78A-02EBCBAA14C2} = {3CD3D9A5-9BC5-4FEB-8D63-4D535C0ABB78}
{7370A62F-12DA-4181-BE3B-009D0926CA7E} = {3CD3D9A5-9BC5-4FEB-8D63-4D535C0ABB78}
{83BA8293-9BC0-496E-A9D4-7F8365BEEFCE} = {B56A6119-1B8F-44E4-9446-291E52F47D4C}
{5EF63907-CB93-4FA0-BA9C-B73EC7001365} = {83BA8293-9BC0-496E-A9D4-7F8365BEEFCE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1A1E8F1D-82B3-471F-9B59-0350DEA9203D}
Expand Down

0 comments on commit 1c4a40b

Please sign in to comment.